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

彻底崩溃!!!!!!!!!

Posted by Nedvid at 2007-10-30 20:43:34 on Problem 2845
#include<stdio.h>
#include<string.h>
void main()
{
	int i,t,j=0,k,m,n,num=0,x,result[102];
	char a[102],b[102];
	scanf("%d",&n);getchar();
	while(n--)
	{
		num++;x=0;
		for(i=0;i<102;i++)
    	result[i]=0;
		if(scanf("%s %s",a,b)==2){
		k=strlen(a);m=strlen(b);
		if(k>m){
		for(i=k-1,t=0;i>=0;i--,t++)
		{
			  result[t]+=(a[i]-'0');
			  if(result[t]>=2)
			  {
			    result[t]=result[t]-2;
			   	result[t+1]+=1;
			  }
		}	
		m=(m>=k?k:m);
		for(i=m-1,t=0;i>=0;i--,t++)
		{
			  result[t]+=(b[i]-'0');
			  if(result[t]>=2)
			  {
			    result[t]=result[t]-2;
			   	result[t+1]+=1;
			  }
		}	
			m=(m>=k?m:k);
			for(i=m-1,t=0;i>=0;i--,t++)
			  if(result[t]>=2)
			  {
			    result[t]=result[t]-2;
			   	result[t+1]+=1;
			  }	
		}
		else{
			for(i=m-1,t=0;i>=0;i--,t++)
		{
			  result[t]+=(b[i]-'0');
			  if(result[t]>=2)
			  {
			    result[t]=result[t]-2;
			   	result[t+1]+=1;
			  }
		}	
		for(i=k-1,t=0;i>=0;i--,t++)
		{
			  result[t]+=(a[i]-'0');
			  if(result[t]>=2)
			  {
			    result[t]=result[t]-2;
			   	result[t+1]+=1;
			  }
		}	
			m=(m>=k?m:k);
			for(i=m-1,t=0;i>=0;i--,t++)
			  if(result[t]>=2)
			  {
			    result[t]=result[t]-2;
			   	result[t+1]+=1;
			  }	
		}
		for(i=101;i>=0;i--)if(result[i]!=0){x=i;break;}
		printf("%d ",num);
		if(x==0)printf("0");
		else
	    for(;x>=0;x--)printf("%d",result[x]);
		printf("\n");}
	}

}


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