언어/c언어

369 게임 (네이버 답변)

파아랑새 2016. 6. 6. 23:31

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void) {
 int i;
 int index = 0;
 printf("369 369 369 369 start!! \n");
 int count = 0;
 int* Game_human = NULL;
 printf("참가할 인원 Enter> : ");
 scanf_s("%d", &count);
 printf("3의 배수를 입력할때는 0을 입력해야 합니다.\n");
 Game_human = (int*)malloc(sizeof(int)*count);
 memset(Game_human, 0, sizeof(int)*count);
 for (i = 0; ; i++) {
  printf("순서%d : 입력 >", (i%count)+1);
  scanf_s("%d", (Game_human + (i%count)));
  index = i%count;
  if ((i + 1) % 3 == 0){
   if (*(Game_human + index) != 0){
    printf("틀렸습니다. \n");
    break;
   }
  }
  else{
   if (*(Game_human + index) != (i + 1)){
    printf("틀렸습니다. \n");
    break;
   }
  }

 

  
 }
 return 0;

}