Advertisement
Guest User

90% Paren Ekvivalent

a guest
Nov 13th, 2019
310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6. int a,b,t1,t2,x=0,x2=0;
  7. scanf("%d %d",&a,&b);
  8. if(a>0&&b>0)
  9. {
  10. x2=1;
  11. if(a>b)
  12. {
  13. t1=a;
  14. t2=b;
  15. }
  16. else
  17. {
  18. t1=b;
  19. t2=a;
  20. }
  21.  
  22. while (t1&&t2)
  23. {
  24. t1=t1/10;
  25. if(t1%10==t2%10)
  26. {
  27. x=1;
  28. }
  29. else
  30. {
  31. x=0;
  32. }
  33. t1/=10;
  34. t2/=10;
  35. }
  36. }
  37. if(x&&x2)
  38. {
  39. printf("PAREN");
  40. }
  41. else if (!x&&x2)
  42. printf("NE");
  43. else if(!x&&!x2)
  44. {
  45. printf("Invalid input");
  46. }
  47. return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement