A number is an even equivalent of another one if the digits of the first one are placed in the even positions of digits of the second one (e.g. 13 and 1234, 198 and 169582...). I am writing a program that checks if two numbers are even equivalents and it doesn't work. Why?
#include <stdio.h>
int main () {
int a, b, t, m, n, diga, digb, pro;
scanf("%d%d", &a, &b);
if((a<=0)&&(b<=0))
printf("Invalid input");
else {
if(b>a){
t=a;
a=b;
b=t;
}
while (n>0)
{
m=a;
n=b;
digb=n%10;
diga=(m%100)/10;
pro=(diga==digb);
if(pro==0) break;
n/=10;
m/=100;
}
if(pro==1) printf("PAREN");
else printf("NE");
}
return 0;
}
Aucun commentaire:
Enregistrer un commentaire