1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | #define _CRT_SECURE_NO_WARNINGS #include <stdio.h> int main(void) { int sticks = 12; int n, computer; srand(time(NULL)); // ³¼öÀÇ ¾¾¾Ñ°ªÀ» ÇöÀç ½Ã°£À¸·Î º¯°æ printf("ÇöÀç ½ºÆ½ÀÇ °³¼ö:%d\n", sticks); while (sticks > 0) { printf("¸î°³ÀÇ ½ºÆ½À» °¡Á®°¡½Ã°Ú½À´Ï±î? : "); scanf("%d", &n); if (n < 1 || n > 3) { printf("1°³ºÎÅÍ 3°³±îÁö °¡´ÉÇÕ´Ï´Ù.\n\n"); continue; } sticks -= n; computer = (rand() % 3) + 1; if (sticks < computer) computer = sticks; sticks -= computer; printf("**ÄÄÇ»ÅÍ´Â %d°³ÀÇ ½ºÆ½À» °¡Á®°¬½À´Ï´Ù.\n", computer); printf("ÇöÀç ½ºÆ½ÀÇ °³¼ö:%d\n\n", sticks); } return 0; } | cs |