Please enable JavaScript in your browser to load website properly.

Click here if you'd like to learn how.

C/C++ 질문합니다. 컴퓨터언어쪽 하실줄 아시는분 질문합니다. [3]

이병 철고구 | 15-04-14 04:00:39 | 조회 : 1316 | 추천 : -


이 소스코드를 설명하라고 한다면 어떻게 설명해야 맞는건가요?






#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
void main(void)
{
    while (1)
   {
      char *strs[] = {"car", "fall", "truck", "flower", "blanket", "elephant"};
       char ch, och;
      int i, j, r, n, a;
      int strs_len = sizeof(strs) / sizeof(strs[0]);
   srand((unsigned)time(NULL));
   puts("#### LET'S PLAY FUNNEL GAME ####");
   a = 0;
   for (i = 0; i < strs_len; i++)
   {
      printf("LEVEL %d: ", i + 1);
    n = strlen(strs[i]);
    r = rand() % n;
    for (j = 0; j < n; j++)
    {
    if (r == j)
    {
     och = strs[i][j];
     putchar('?');
    }
    else
    {
     putchar(strs[i][j]);
    }
   }
   printf("n맞춰봐: ");
   scanf("%c", &ch);
   while ('n' != getchar());
   if (och == ch)
   {
    a++;
    puts("딩동댕!!nn");
   }
   else
   {
    puts("땡!!nn");
   }
  }
  printf("모두 %d개 맞추셨군요.n다시 할래요? (y/n) ", a);
  scanf("%c", &ch);
      while ('n' != getchar());
      if (ch == 'n') {
         break;
      }
      else
     {
         puts("n");
      }
   }
}
SNS로 공유하기
< 1 2 3 4 5 >