Advertisement
LegoDrifter

Paren ekvivalent

Nov 25th, 2020
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.83 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4.  
  5.  
  6. int main()
  7. {
  8.     int N,X,max,min,ctr=1,flag=0;
  9.     scanf("%d%d",&N,&X);
  10.     if(N<=0 || X<=0)
  11.     {
  12.         printf("Invalid input");
  13.     }
  14.     else
  15.     {
  16.     if(N>X)
  17.     {
  18.         max=N;
  19.         min=X;
  20.     }
  21.     else
  22.     {
  23.         max=X;
  24.         min=N;
  25.     }
  26.     while(max)
  27.     {
  28.         if(ctr%2==0)
  29.         {
  30.             if(max%10 == min%10)
  31.             {
  32.                 flag=1;
  33.                 max /= 10;
  34.                 min /= 10;
  35.             }
  36.             else
  37.             {
  38.                 flag=0;
  39.                 break;
  40.             }
  41.         }
  42.         else
  43.         {
  44.             max/=10;
  45.         }
  46.         ctr++;
  47.  
  48.     }
  49.     if(flag==0)
  50.     {
  51.         printf("NE");
  52.     }
  53.     else
  54.         printf("PAREN");
  55.     }
  56.  
  57.  
  58.  
  59.     return 0;
  60. }
  61.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement