#pragma warning(disable:4996)
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int throwDice();
int getUserGuess();
void playGuessGame();
int throwDice() {
return rand() % 6 + 1;
}
int getUserGuess() {
int guess;
printf("μ£Όμ¬μλ₯Ό λμ λμ¬ μ«μλ₯Ό λ§ν보μΈμ (1μμ 6κΉμ§): ");
scanf("%d", &guess);
return guess;
}
void playGuessGame() {
int userGuess, diceResult;
while(1) {
userGuess = getUserGuess();
diceResult = throwDice();
if (userGuess == 0) {
printf("κ²μμ μ’
λ£ν©λλ€.\n");
break;
}
else if (!(userGuess >= 1 && userGuess <= 6)) {
printf("μλͺ»λ κ°μ μ
λ ₯νμ΅λλ€.\n");
continue;
}
printf("μ£Όμ¬μ κ²°κ³Ό: %d\n", diceResult);
if (userGuess == diceResult) {
printf("μΆνν©λλ€! μ«μλ₯Ό λ§νμ΅λλ€!\n");
}
else {
printf("μμ½μ΅λλ€. λ€μ μλνμΈμ.\n");
}
}
}
int main() {
srand(time(NULL));
printf("μ£Όμ¬μ λ§νκΈ° κ²μμ μμν©λλ€.\n");
playGuessGame();
printf("κ²μ μ’
λ£\n");
return 0;
}