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