Advertisement
deko96

Парен еквивалент

Nov 7th, 2014
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.67 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5.     int a, b, tmp, cifra_a, cifra_b, found = 1;
  6.     scanf("%d %d", &a, &b);
  7.  
  8.     if(a <= 0 || b <= 0)
  9.     {
  10.         printf("Invalid input");
  11.     } else {
  12.  
  13.        if(a < b) {
  14.            tmp = a;
  15.            a = b;
  16.            b = tmp;
  17.        }
  18.  
  19.        while(a > 0&&b > 0)
  20.        {
  21.            a /= 10;
  22.            cifra_a = a % 10;
  23.            a /= 10;
  24.            cifra_b = b % 10;
  25.            b /= 10;
  26.  
  27.            if(cifra_a != cifra_b) {
  28.                 found = 0;
  29.                 break;
  30.            }
  31.        }
  32.        if(found == 0)
  33.         printf("NE");
  34.        else
  35.         printf("PAREN");
  36.  
  37.     }
  38.  
  39.     return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement