MUstar

IoT C언어 0626 - ex_03

Jun 26th, 2017
84
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2.  
  3. void input_nums(int *lotto_nums);
  4. void print_nums(int *lotto_nums);
  5.  
  6. int main(void)
  7. {
  8.     int lotto_nums[6];
  9.  
  10.     input_nums(lotto_nums);
  11.     print_nums(lotto_nums);
  12.  
  13.     return 0;
  14. }
  15.  
  16. void input_nums(int *lotto_nums)
  17. {
  18.     int cnt, temp_num;
  19.     while(cnt < 6)
  20.     {  
  21.         int cksum=0;
  22.         printf("번호 입력 : ");
  23.         scanf("%d", &temp_num);
  24.         for(int scan=0;scan<cnt;scan++)
  25.         {
  26.             if(lotto_nums[scan]==temp_num) cksum=1;
  27.         }
  28.         if (cksum==1) printf("같은 번호가 있습니다.\n");
  29.         else
  30.         {
  31.             lotto_nums[cnt] = temp_num;
  32.             cnt++;
  33.         }
  34.     }
  35. }
  36.  
  37. void print_nums(int *lotto_nums)
  38. {
  39.     printf("로또 번호 : ");
  40.     for(int op=0;op<6;op++)
  41.     {
  42.         printf("%d ",lotto_nums[op]);
  43.     }
  44.     printf("\n");
  45. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×