Advertisement
cd62131

FourNumbers

Jul 1st, 2014
414
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.79 KB | None | 0 0
  1. #include <stdio.h>
  2. #define TRUE (1)
  3. #define FALSE !TRUE
  4. int sum(int a, int b, int c, int d) {
  5.   int s = a + b + c + d;
  6.   if (15 <= s && s <= 24) return TRUE;
  7.   return FALSE;
  8. }
  9. int odd(int a, int b, int c, int d) {
  10.   int o = (a % 2 == 0) + (b % 2 == 0) + (c % 2 == 0) + (d % 2 == 0);
  11.   if (o == 1 || o == 2) return TRUE;
  12.   return FALSE;
  13. }
  14. int small(int a, int b, int c, int d) {
  15.   int s = (a < 5) + (b < 5) + (c < 5) + (d < 5);
  16.   if (s == 2 || s == 3) return TRUE;
  17.   return FALSE;
  18. }
  19. int main(void) {
  20.   int a, b, c, d;
  21.   for (a = 0; a < 10; a++)
  22.     for (b = a + 1; b < 10; b++)
  23.       for (c = b + 1; c < 10; c++)
  24.         for (d = c + 1; d < 10; d++)
  25.           if (sum(a, b, c, d) && odd(a, b, c, d) && small(a, b, c, d))
  26.             printf("%d %d %d %d\n", a, b, c, d);
  27.   return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement