Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
为什么总是WA呢?郁闷的很啊!#include<stdio.h> #include<string.h> int main() { void daoxu(char s[10]); int a,b,c,i,e,f,num,data[1000],loc[1000],sum; char s[10000],s1[10],s2[10],s3[10]; while(scanf("%s",s)==1) { if(strcmp(s,"0+0=0")==0) {printf("True\n");break;} loc[0]=-1;num=1; for(i=0;s[i];i++) if(s[i]=='+'||s[i]=='=') loc[num++]=i; sum=0; for(i=0;i<num-1;i++) { sscanf(s+1+loc[i],"%d+",&a); sprintf(s1,"%d",a); daoxu(s1); sscanf(s1,"%d",&a); sum+=a; } sscanf(s+1+loc[num-1],"%d",&a); sprintf(s1,"%d",a); daoxu(s1); sscanf(s1,"%d",&a); if(a==sum) printf("True\n"); else printf("False\n"); } return 0; } void daoxu(char s[10]) { int m=strlen(s); char t; for(int i=0;i<m/2;i++) { t=s[i];s[i]=s[m-1-i];s[m-1-i]=t; } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator