C Program Paren Ekvivalent



//Paren Ekvivalent

#include <stdio.h>

int main()
{
 int a,b;
  
    scanf("%d%d", &a, &b);
    if(a<=0 || b<=0)
        printf("Invalid input");
    else {
        if (b>a)
        {
            int tmp=a;
            a=b;
            b=tmp;
        }
        int tmp1 = a;
        int tmp2 = b;
        int flag = 0;
        int counter = 1;
        while(tmp1 != 0&&tmp2 != 0) {
            int cifra = tmp1 % 10;
            int cifra2 = tmp2 % 10;
            if(counter % 2 == 0) {
                if(cifra == cifra2)
                    flag = 1;
                else {
                    flag = 0;
                    break;
                }
                tmp2 /= 10;
            }
            tmp1 /= 10;
            
            counter++;
        }
        if(flag)
            printf("PAREN");
        else
            printf("NE");
    }
    return 0;
}


Learn More :