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 | #define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <conio.h> #include <string.h> int main(void) { char solution[100] = "meet at midnight"; // Á¤´äÀÌ µé¾î ÀÖ´Â ¹®ÀÚ ¹è¿ char answer[100] = "____ __ ________"; // ÇöÀç±îÁö »ç¿ëÀÚ°¡ ¸ÂÃá ¹®ÀÚ¿ char ch; int i; while (1) { printf("\n¹®ÀÚ¿À» ÀÔ·ÂÇϽÿÀ: %s \n", answer); printf("±ÛÀÚ¸¦ ÃßÃøÇϽÿÀ: "); ch = _getch(); // »ç¿ëÀÚ°¡ ÀÔ·ÂÇÑ ¹®ÀÚ¸¦ answer[]¿¡ ³Ö¾î¼ Á¤´äÀ» ºñ±³ÇÑ´Ù. for (i = 0; solution[i] != '\0'; i++) { // »ç¿ëÀÚ°¡ ¸ÂÃß¾úÀ¸¸é ±ÛÀÚ¸¦ º¸ÀÌ°Ô ÇÑ´Ù. if (solution[i] == ch) answer[i] = ch; } if (strcmp(solution, answer) == 0) break; // Á¤´ä°ú ÀÏÄ¡ÇÏ´ÂÁö¸¦ °Ë»ç } return 0; } | cs |