#include "stdafx.h" #include <STDLIB.H>
int Randomize(int nMax, bool range);
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { // TODO: Place code here. char szText[16][MAX_PATH] = { "Randomize = 0", "Randomize = 1", "Randomize = 2", "Randomize = 3", "Randomize = 4", "Randomize = 5", "Randomize = 6", "Randomize = 7", "Randomize = 8", "Randomize = 9", "Randomize = 10", "Randomize = 11", "Randomize = 12", "Randomize = 13", "Randomize = 14", "Randomize = 15", };
MessageBox(NULL,szText[Randomize(16,FALSE)], "Randomize",MB_OK);
return 0; }
int Randomize(int nMax, bool range) { srand(GetTickCount()); int random_integer = (rand()%nMax); if(range){random_integer++; return random_integer;}
return random_integer; } |