/*
written by cyuyan
*/
#include<stdio.h>
#include<string.h>
#define N 7
/*求反串*/
void reverse(char* str,char *re_str)
{
int i,j;
for(i=strlen(str)-1,j=0;i>=0;i--,j++)
re_str[j]=str[i];
re_str[j]='\0';
}
/*从等式中提取a,b,c*/
void change_to_int(char *str,int *a,int *b,int *c)
{
char stra[N],re_stra[N],strb[N],re_strb[N],strc[N],re_strc[N];
int j,k;
for(j=0,k=0;str[j]!='+';j++,k++)
stra[k]=str[j];
stra[k]='\0';
for(j=j+1,k=0;str[j]!='=';j++,k++)
strb[k]=str[j];
strb[k]='\0';
for(j=j+1,k=0;str[j]!='\0';j++,k++)
strc[k]=str[j];
strc[k]='\0';
reverse(stra,re_stra);
sscanf(re_stra,"%d",a);
reverse(strb,re_strb);
sscanf(re_strb,"%d",b);
reverse(strc,re_strc);
sscanf(re_strc,"%d",c);
}
void main()
{
char buf[30];
int a[N],b[N],c[N],i;
for(i=0;i<N;i++)/*输入*/
{
gets(buf);
change_to_int(buf,&a[i],&b[i],&c[i]);
}
for(i=0;i<N;i++)/*判定并输出*/
{
if(a[i]+b[i]==c[i]) printf("True\n");
else printf("False\n");
}
}
==================================================
在win xp和vc++6.0下调试通过