Advertisement
MUstar

IoT C언어 0522 - EX_3

May 22nd, 2017
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.50 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main(void)
  4. {
  5.     int num[6];
  6.     int tn , cnt=0, i;
  7.     while(cnt<6)
  8.     {  
  9.         int cs=0;
  10.        
  11.         printf("로또번호 입력 : ");
  12.         scanf("%d", &tn);
  13.         for(i=0;i<6;i++)
  14.         {
  15.             if(tn == num[i])
  16.             {
  17.                 cs++;
  18.                 break;
  19.             }
  20.         }
  21.         if (cs==0)
  22.         {
  23.             num[cnt] = tn;
  24.             cnt++; 
  25.         }
  26.         else
  27.         {
  28.             printf("같은 번호가 있습니다!\n");
  29.         }
  30.     }
  31.     printf("입력된 로또번호 : ");
  32.     for(i=0;i<cnt;i++)
  33.     {
  34.         printf("%5d", num[i]);
  35.     }
  36.     printf("\n");
  37.    
  38.     return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement