online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
#include <stdio.h> #include <stdlib.h> #include <time.h> int generateNumber(int n1, int n2){ int num; do { num = rand() % 9 + 1; }while (num == n1 || num == n2); return num; } int getInput(int prompt){ int num; while(1) { printf("%d번째 숫자 (1~9): ", prompt); scanf("%d", &num); if (num >= 1 && num <= 9){ return num; } else{ printf("잘못된 입력입니다. 1~9 사이의 수를 입력하세요.\n"); } } } int checkGuess(int com1, int com2, int com3, int user1, int user2, int user3){ int strike = 0; int ball = 0; if (com1 == user1) strike++; if (com2 == user2) strike++; if (com3 == user3) strike++; if (com1 == user2 || com1 == user3) { ball++; } if (com2 == user1 || com2 == user3) { ball++; } if (com3 == user1 || com3 == user2) { ball++; } printf("결과: %d strike, %d ball\n", strike, ball); return strike; } void playGame() { printf("게임을 시작합니다.\n"); int com1 = generateNumber(0, 0); int com2 = generateNumber(com1, 0); int com3 = generateNumber(com1, com2); int round = 0; int user1, user2, user3; int strike; while(1){ round++; while(1){ user1 = getInput(1); user2 = getInput(2); if (user1 == user2){ printf("중복 수는 입력할 수 없다.\n"); continue; } user3 = getInput(3); if (user3 == user1 || user3 == user2){ printf("중복 수는 입력할 수 없다.\n"); continue; } break; } strike = checkGuess(com1, com2, com3, user1, user2, user3); if (strike == 3) { printf("3 스트라이크! 정답입니다! 총 %d round만에 성공!\n", round); break; } } } int main() { srand(time(NULL)); playGame(); return 0; }

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue