난수 헬프
갈기슭
#include stdio.h
#include stdlib.h
#include windows.h
#include conio.h
#include fstream.h
#define col GetStdHandle(STD_OUTPUT_HANDLE) // 콘솔창의 핸들정보 받기
#define RED SetConsoleTextAttribute( col,0x000c ); //빨간색
#define BLUE SetConsoleTextAttribute( col,0x0001 | 0x0008); //파란색
#define HIGH SetConsoleTextAttribute( col,0x00a); // 연두
#define WHITE SetConsoleTextAttribute( col,0x000f); // 흰색
#define SKY SetConsoleTextAttribute( col, 0x000b); //하늘색
#define YEL SetConsoleTextAttribute( col, 0x000e); //노란색
#define HIG SetConsoleTextAttribute( col, 0x000d); //형광
#define VIO SetConsoleTextAttribute( col,0x0001 | 0x0008 |0x000c); //보라
void print();
int dice(int nFrom, int nTo);
void main(void)
{
HWND hWnd = FindWindow(ConsoleWindowClass,NULL);
if (hWnd != NULL);
SendMessage(hWnd,WM_SYSKEYDOWN ,VK_RETURN,0x211C0001);
char munjae[10000];
int dap1;
int dap2;
int dap3;
int userdap;
ifstream fin;
ofstream fout;
int counter;
int jumsu;
print();
counter=+1;
dap1=dice(500,1000);
dap2=dice(1000,8000);
printf(%d+%d=?, dap1, dap2);
scanf(%d,&userdap);
dap3=dap1+dap2;
if(userdap==dap3)
{
jumsu = jumsu+1;
}
}
void print()
{
printf (⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙\n);
printf (⊙ ⊙\n);
printf (⊙ ⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙ ⊙\n);
printf (⊙ ⊙ ⊙ ⊙\n);
printf (⊙ ⊙ ⊙ ⊙\n);
printf (⊙ ⊙ ⊙ ⊙\n);
printf (⊙ ⊙ ⊙ ⊙\n);
printf (⊙ ⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙ ⊙\n);
printf (⊙ ⊙\n);
printf (⊙ ⊙\n);
printf (⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙\n);
printf (⊙ ⊙\n);
printf (⊙ ⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙ ⊙\n);
printf (⊙ ⊙ ⊙ ⊙\n);
printf (⊙ ⊙ ⊙ ⊙\n);
printf (⊙ ⊙ ⊙ ⊙\n);
printf (⊙&; ⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙ ⊙\n);
printf (⊙ ⊙\n);
printf (⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙⊙\n);
}
int dice(int nFrom, int nTo)
{
return (rand() % (nTo - nFrom +1)) + nFrom;
}
미완성이긴 합니다.
그건 그렇다 치고, 왜 실행시킬때마다 dice의 값이 같을까요?
-
종달
검색어 srand을 추천합니다.