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

我去!!用EOF居然WA!!附代码!!!

Posted by wocha at 2012-04-21 12:24:58 on Problem 2845
#include<stdio.h>
#include<string.h>
#include<memory.h>
char str1[111],str2[222],str3[111];
char * strrev_(char *str)
{
        int n = strlen(str);
        char* begin = str;
        char* end = str + n - 1;
        while (begin < end) {
                char tmp = *begin;
                *begin = *end;
                *end = tmp;
                ++begin;
                --end;
        }
        return str;
}
int main()
{
	int N,i,j,n,m,q,p,l;
	 scanf("%d",&N);
	{
		getchar();
		p=N;
		while(N--)
		{
			memset(str1,'0',sizeof(str1));
			memset(str2,'0',sizeof(str2));
			scanf("%s %s",str1,str2);
			strrev_(str1);
			strrev_(str2);
			n=strlen(str1);
			m=strlen(str2);
			int max=n>m?n:m;
			
			str1[n]='0';
			str2[m]='0';
			int e=0;
			for(i=0;i<=max;i++)
		 {
				 if(str1[i]+str2[i]-'0'+e<='1')
				 {
					 str3[i]=str1[i]+str2[i]-'0'+e;
					 e=0;
				 }
				 else
				 {
						str3[i]=str1[i]+str2[i]-'0'+e-2;
						e=1;
				 }
			}

			for(i=max;i>=0;i--)
			{
				if(str3[i]!='0') break;
			}
	
				str3[i+1]='\0';
				int f=strlen(str3);
				 strrev_(str3);
				 
				printf("%d ",p-N);
				if(i==-1) printf("0\n");
			
			else {
			for(i=0;i<f;i++)
				putchar(str3[i]);
				printf("\n");
			}
		}
	}





return 0;

}

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