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
#include <iostream>
void main(){
    int a[10]={0},input,i=0,j=9, count=1;
 
    while(1) {
        std::cout<<count<<"입력: ";
        std::cin>>input;
        if (input == 0)
            break;
        if (input%2 == 1) {
            a[i]=input;//홀수
            for(int i=0; i<=9; i++)
                std::cout<<a[i];
            i++;
            std::cout<<"\n";
        }
        else {
            a[j]=input;//짝수
            for(int i=0; i<=9; i++)
                std::cout<<a[i];
            j--;
            std::cout<<"\n";
        }
        count++;
        if (a[5!= 0)
            break;
    }
    for(int i=0; i<=9; i++)
        std::cout<<"a["<<i<<"]="<<a[i]<<"\n";
}
cs

윈도우 프로그래밍 실습


사용자에게 입력받아 홀수면 왼쪽, 짝수면 오른쪽에 저장한다


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


+ Recent posts