난수 발생하기

Study/C++ 2011. 9. 29. 20:14
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
#include <iostream>
 
using namespace std;
 
void main(int argc, char* argv[])
{
    srand(time(NULL));
 
    int mines[5][5], i, j;
 
    for(i = 0; i < 5; i++){
        for(j = 0; j < 5; j++){
            int temp = rand() % 2;
            cout << temp << endl;
            mines[i][j] = temp;
        }
    }
 
    for(i = 0; i < 5; i++){
        for(j = 0; j < 5; j++){
            cout << mines[i][j] << " ";
        }
        cout << endl;
    }
}

'Study > C++' 카테고리의 다른 글

빙고 게임  (0) 2011.09.29
동적 할당하기  (0) 2011.09.29
IT CookBook, C++ 프로그래밍 기초 연습문제 해답  (0) 2011.09.03
포인터  (0) 2011.09.03
C++ 클래스  (0) 2011.09.03
Posted by 코딩하는 야구쟁이
,