Advertisement
MUstar

IoT C언어 0626 - ex_02

Jun 26th, 2017
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.54 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int check_same(int *lotto_nums,int *my_nums);
  4.  
  5. int main(void)
  6. {
  7.     int lotto_nums[6] = {4, 10, 25, 30, 41, 45};
  8.     int my_nums[6] = {1, 4, 7, 22, 41, 43};
  9.    
  10.     check_same(lotto_nums, my_nums);
  11.    
  12.     return 0;
  13. }
  14.  
  15. int check_same(int *lotto_nums,int *my_nums)
  16. {
  17.     int cnt=0 , cknum=0;
  18.     while(cnt<6)
  19.     {
  20.         for(int i=0;i<6;i++)
  21.         {
  22.             if(lotto_nums[cnt]==my_nums[i]) cknum++;
  23.         }
  24.         cnt++;
  25.     }
  26.     if (cknum == 0)printf("일치하지 않는 숫자가 없어요,\n");
  27.     else printf("일치하는 번호의 개수 : %d\n", cknum);
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement