SHARE
TWEET

Untitled

a guest Nov 14th, 2019 87 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2.  
  3. int
  4. findSmallestNumber (int arr[], int len)
  5. {
  6.   int min = arr[0];
  7.   for (int i = 0; i < len; i++)
  8.     {
  9.       if (min > arr[i])
  10.     {
  11.       min = arr[i];
  12.     }
  13.     }
  14.   return min;
  15. }
  16.  
  17. int
  18. all_even (int number)
  19. {
  20.   int i = 0, digit;
  21.   int odd = 0;
  22.   int num = number;
  23.   while (num != 0)
  24.     {
  25.       number = num / 10;
  26.       digit = num % 10;
  27.  
  28.       if (digit % 2 != 0)
  29.     {
  30.       odd = 1;
  31.       break;
  32.     }
  33.       num = number;
  34.     }
  35.  
  36.   if (odd == 1)
  37.     {
  38.       return 0;
  39.     }
  40.   else
  41.     {
  42.       return 1;
  43.     }
  44. }
  45.  
  46. int
  47. main ()
  48. {
  49.  
  50.   int m, n, k = 0, allEven[100];
  51.   scanf ("%d%d", &m, &n);
  52.  
  53.   for (int i = m; i < n; i++)
  54.     {
  55.       if (all_even (i) == 1)
  56.     {
  57.       allEven[k] = i;
  58.       k++;
  59.     }
  60.     }
  61.  
  62.  
  63.   if (k == 0)
  64.     printf ("NE");
  65.   else
  66.     printf ("%d", findSmallestNumber (allEven, k));
  67.  
  68.   return 0;
  69. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top