로딩
요청 처리 중입니다...

난수 활용 - 가위바위보 게임

 난수 활용 - 가위바위보 게임

/*가위,바위,보 중 하나를 10회 임의 생성하는 프로그램*/ #include #include //srand(), rand() #include //time() int main(){ srand(time(NULL)); // 1970년 1월 1일 0시 이후로 경과된 초 단위의 수를 반환 int i; for(i=0; i<10; i++){ if(rand()%3 == 0) printf("가위\n"); else if(rand()%3 ==1) printf("바위\n"); else printf("보\n"); } } 아래와 같이 가위, 바위, 보가 랜덤으로 10번 출력됩니다. 아래 코드는 승률을 계산해주는 가위, 바위, 보 게임입니다.

#include #include #include #include #define LEN 1024 int main(){ int you = 0, c...

# c언어 # rand함수 # 가위바위보게임 # 가위바위보승률 # 난수