Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:sscanf(s+1+loc[i],"%d+",&a);这样输入有问题!!!!073变成73!!逆转后就完全错了.用字符串处理吧..

Posted by wsbear at 2006-07-30 21:22:16 on Problem 2572
In Reply To:为什么总是WA呢?郁闷的很啊! Posted by:hubo430 at 2006-07-18 17:20:48
> #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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator