#include < stdio.h  > 
#include < stdlib.h > 
 #include < time.h   >
#include <windows.h>

#define col GetStdHandle(STD_OUTPUT_HANDLE)
#define BLUE SetConsoleTextAttribute( col, 0x0001 | 0x0008);
#define GREEN SetConsoleTextAttribute( col, 0x0002);
#define GOLD SetConsoleTextAttribute( col, 0x0006);


 
void make_num();
 void scan_check();
 void print_all();


int num[3], player[20];
 int strike[20], ball[20], trial;


  int main()
 {
 
 puts("[숫자 야구 게임] 0~9까지 숫자중 3자리 숫자를 선택하세요. 주어진 기회는 20회 입니다.");
  
 
      make_num();


   scan_check();


      print_all();
  
 
 fflush(stdin);


      getchar();
  return 0;
 }


void make_num()
 {
  int i;


   srand(time(NULL));
  
 
 while (1)
  {
 
        for (i = 0; i < 3; i++)
    num[i] = rand() % 10;
  
 
  if (num[0] != num[1] && num[1] != num[2] && num[0] != num[2] && num[0] != 0)
             break;
  }
 }


void scan_check()
  {
  int i, j, k;
     int check[3];


    for (i = 0; i < 20; i++)
  {
   trial++; 
 

     BLUE; printf(" 선택하신 3자리 수는 : ");
   scanf("%d", &player[i]);
  
 
  check[0] = player[i] / 100;
         check[1] = (player[i] % 100) / 10;
   check[2] = player[i] % 10;
  
 
  if (check[0] == check[1] || check[1] == check[2] || check[0] == check[2] || check[0] == 0)
   {
 
            printf("다시 입력해 주세요.");
 
   trial--;
             i--;  
        }
   else
   { 
    for (j = 0; j < 3; j++)
    {
                 if (num[j] == check[j])
     {
                     strike[i]++;
     }
    }
  
   
   
     for (j = 0; j < 3; j++)
    {
     for(k = 0; k < 3; k++)
     {
      if (num[j] == check[k])
       ball[i]++;
     }
    }
  
    ball[i] -= strike[i];
 
   
      GREEN; printf("Trial = %d Strike = %d Ball = %d ", trial, strike[i], ball[i]);
   
 
   if(strike[i] == 3) return;
         }
  }


GOLD; printf("주어진기회동안 맞추질 못하였습니 ");
  GOLD; printf("정답은 %d %d %d 입니다 " , num[0] , num[1] , num[2] ) ;
 }


void print_all()
 {
  int i;
 
 for (i = 0; i < trial; i++)
  {
         printf("-[%d]: %d %d/S %d/B ", i + 1, player[i], strike[i], ball[i]);
  }
 }


숫자야구게임인데 몇번만에 빨리맞췄는지 랭킹하는거 랑

숫자적을떄마다 이전숫자 적은거 기억할수있게 누적해서 나타낼수있게 도와주세요