수업/C언어 강의2012. 9. 1. 03:54

#include<stdio.h>

#include<stdlib.h>

#include<time.h>

/*

int main(){


int a;

srand(time(NULL));//타이머를 사용하여 매번 다른 난수를 발생

//난수 범위 : 시작수 + rand() % 개수

//1 + rand() % 10

//10부터 20까지 난수 : 10 + rand()%11

a = rand();


printf("%d\n",a);

return 0;

}

*/


int main(){

int p,c,d;


srand(time(NULL));

c = 1 + rand()%3; //1부터 3까지 난수 발생

d = 1 + rand()%3;

printf("가위 ->1, 바위 ->2, 보 ->3을 입력하세요/\n");

scanf("%d", &p);


printf("당신은 %d, 컴은 %d, 컴2는 %d입니다.\n", p, c, d);


return 0;

}

'수업 > C언어 강의' 카테고리의 다른 글

9월 7일 C언어  (0) 2012.09.07
9월 6일 C언어  (0) 2012.09.06
8월 30일 C언어  (0) 2012.09.01
8월 24일 C언어  (0) 2012.08.24
5월 23일 C언어  (0) 2012.05.23
Posted by 멜데스