1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <iostream>
#include <time.h>
#include <Windows.h>
 
void main(){
    int a[50]={0},input,i=0,j=49, count=0;
    srand(time(NULL));
    while(1) {
        input=rand() % 9 + 1;
        if (input%2 == 1) {
            a[i]=input;//홀수
            for(int i=0; i<=49; i++)
                std::cout<<a[i];
            i++;
            std::cout<<"\n";
        }
        else {
            a[j]=input;//짝수
            for(int i=0; i<=49; i++)
                std::cout<<a[i];
            j--;
            std::cout<<"\n";
        }
        count++;
        if (count==49) {
            for(int i=0; i<=49; i++
                a[i]=0;
            i=0,j=49;
            count=0;
        }
        Sleep(50);
    }    
}
cs


윈도우 프로그래밍 실습


난수를 발생시켜 홀수면 왼쪽, 짝수면 오른쪽에 저장한다


난수 50개가 전부 차면 0으로 초기화 한다

+ Recent posts