728x90
출처 : 반크_세계무형유산 아리랑, 판소리
참고풀이]
//Dev-C++ 5.11로 작업함.
#include <stdio.h>
#include <stdlib.h> //srand(), rand()
#include <time.h> //time()
int Dice()
{
int n;
n=rand()%6;
return (n==0) ? 6 : n;
}
int main()
{
int x,y,z;
int Player;
int a,b,c;
int Computer;
//실행할 때 마다 값이 틀리도록 초기화 작업.
srand(time(NULL));
x=Dice(); y=Dice(); z=Dice();
Player=x+y+z;
printf("사용자 주사위=(");
printf("%d,%d,%d)=%d\n",x,y,z,Player);
a=Dice(); b=Dice(); c=Dice();
Computer=a+b+c;
printf("컴퓨터 주사위=(");
printf("%d,%d,%d)=%d\n",a,b,c,Computer);
if(Player>Computer)
printf("사용자 승리\n");
else if(Player==Computer)
printf("사용자와 컴퓨터가 비겼습니다.\n");
else
printf("컴퓨터 승리\n");
return 0;
}
참고풀이 결과]
대한민국의 아름다운 영토, 독도의 겨울
반응형
댓글