가위바위 보 게임입니다. 이렇게 길어도되나요..?
도움
srand 난수로 만들었습니다. 그런데 이렇게 소스가 길면 만든 의미가 있을까요?ㅠㅠ아직 실력이 미비해서 못줄이겠는데..더줄일수있나요?
#includestdio.h#includetime.h#includestdlib.hvoid srand(unsigned int seed);
int main(void){ int n; int com; int s=0,m=0;
srand((int)time(NULL));
while(1){ printf(1.가위 2.바위 3.보 선택:); scanf(%d,&n); com=(rand()%3)+1;
if(n==1){ if(com==1){ printf(당신의 가위, 컴퓨터는 가위. 비겼습니다.\n); m++; continue; } else if(com==2){ printf(당신은 가위, 컴퓨터는 바위. 졌습니다.\n); break; } else{ printf(당신은 가위, 컴퓨터는 보. 이겼습니다.\n); s++; continue; } } else if(n==2){ if(com==1){ printf(당신의 바위, 컴퓨터는 가위. 이겼습니다.\n); s++; continue; } else if(com==2){ printf(당신은 바위, 컴퓨터는 바위. 비겼습니다.\n); m++; continue; } else{ printf(당신은 바위, 컴퓨터는 보. 졌습니다.\n); break; } } else if(n==3){ if(com==1){ printf(당신의 보, 컴퓨터는 가위. 졌습니다.\n); break; } else if(com==2){ printf(당신은 보, 컴퓨터는 바위. 이겼습니다.\n); s++; continue; } else{ printf(당신은 보, 컴퓨터는 보. 비겼습니다.\n); m++; continue; } } else{ printf(잘못 누르셨습니다.종료합니다\n); break; } } printf(게임의 결과 %d승 %d무\n,s,m); return 0;}
-
황소눈
감사합니다ㅠㅠ..이렇게 힘을 주시니 공부할 맛이생기네여!ㅎㅎ
-
샤인
읽다 말았습니다만, 정말 잘 작성하셨어요.
뭐랄까, 컴퓨터를 반절은 이해하고 있어보인다랄까요..
이런게 오락가락하는 사람들에게는 독이지요.ㅎㅎㅎ