online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
#include <stdio.h> #include <stdlib.h> #include <time.h> // 1~9 μ‚¬μ΄μ—μ„œ n1, n2와 λ‹€λ₯Έ λ‚œμˆ˜ 생성 int generateNumber(int n1, int n2) { int n; do { n = rand() % 9 + 1; // 1~9 사이 λ‚œμˆ˜ } while (n == n1 || n == n2); return n; } /*int generateNumber(int num1, int num2){ int randnum; while(1){ randnum = rand() % 9 + 1; if(randnum != num1 && randnumn != num2){ break; } } return randnum; }*/ // μ‚¬μš©μž μž…λ ₯ λ°›κΈ° (1~9 사이 숫자) int getInput(int prompt) { int num; printf("%d 번째 숫자 (1~9): ", prompt); scanf("%d", &num); return num; } // 컴퓨터와 μ‚¬μš©μž μž…λ ₯ 비ꡐ ν›„ κ²°κ³Ό 좜λ ₯ 및 슀트라이크 수 λ°˜ν™˜ int checkGuess(int com1, int com2, int com3, int user1, int user2, int user3) { int strike = 0, ball = 0; if (user1 == com1) strike++; if (user2 == com2) strike++; if (user3 == com3) strike++; if (user1 == com2 || user1 == com3) ball++; if (user2 == com1 || user2 == com3) ball++; if (user3 == com1 || user3 == com2) ball++; printf("κ²°κ³Ό: %d 슀트라이크, %d λ³Ό\n", strike, ball); return strike; } //κ²Œμž„ 본체 void playGame(){ int com1, com2, com3; int user1, user2, user3; int round = 0; com1 = generateNumber(0,0); com2 = generateNumber(com1,0); com3 = generateNumber(com1,com2); printf("⚾ 숫자 야ꡬ κ²Œμž„μ„ μ‹œμž‘ν•©λ‹ˆλ‹€!\n"); while(1){ user1 = getInput(1); user2 = getInput(2); user3 = getInput(3); if(user1 < 1 || user1 > 9 || user2 < 1 || user2 > 9 || user3 < 1 || user3 > 9){ printf("1~9사이 숫자만 μž…λ ₯ν•˜μ„Έμš”.\n"); continue; } if (user1 == user2 || user1 == user3 || user2 == user3){ printf("μ„œλ‘œ λ‹€λ₯Έ 숫자λ₯Ό μž…λ ₯ν•˜μ„Έμš”.\n"); } round++; if(checkGuess(com1, com2, com3, user1, user2, user3)==3){ printf("3 슀트라이크! μ •λ‹΅μž…λ‹ˆλ‹€! 총 %dλΌμš΄λ“œ λ§Œμ— 성곡!\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