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

各位路过的牛人帮忙看看为啥wa?讨论的数据都过啦~汗~多谢各位了

Posted by 19891215 at 2009-05-21 21:59:27 on Problem 2845
#include <iostream>
using namespace std;
int flag=0;
char jia(char a,char b)
{
	char s;

	if (flag==1)
	{
		if (a!=b)
		{
			s='0';
			flag=1;
		}
		else
		{
			s='1';
			if(a=='1')
				flag=1;
			else
				flag=0;
		}
	}
		else
	{
			if (a!=b)
	{
		s='1';
		flag=0;
	}
	else
	{

		s='0';
		if (a=='1')
			flag=1;
		else
			flag=0;
	}
	}
		return s;

}
int main()
{
	//char a[100]={0},b[100]={0},s[100]={0},d[200]={0};
  int m,n,i,j,k,o,flag=0;
 
  cin>>n;
  for (i=0;i<n;i++)
  {
	  
char a[100],b[100],s[100],d[200];
	   for (m=0;m<100;m++)
	   {
	  a[m]=b[m]=s[m]='0';
	   }
  for (m=0;m<200;m++)
	  d[m]=' ';
	  fflush(stdin);
	  gets(d);
    for (j=0;;j++)
	{
		
		if (d[j]==' ')
		{
			j++;
			a[j]='\0';
			break;
		}
		a[j]=d[j];
		
	}
	for (k=j;;k++)
	{
	
		if (d[k]=='\0')
		{
	       b[k-j+1]='\0';
			break;
		}
		b[k-j]=d[k];
		
	}
	
	
		k=k-j;
		j--;
		o=0;
		while (j>0&&k>0)
		{
		
		s[o++]=jia(a[--j],b[--k]);
		
			


		}
		
	    if (k>0)
		{
			while(k>0)
		s[o++]=jia(b[--k],'0');
		
		}
		 if (j>0)
		{	
			 while(j>0)
		s[o++]=jia(a[--j],'0');
	
           
		}
s[o++]=jia('0','0');
		cout<<(i+1)<<" ";
	    flag=0;
		for (k=o-1;k>=0;k--)
		{
				if (s[k]!='0')
			flag=1;
			if (flag==1)
			cout<<s[k];
			else if (k==0)
	cout<<s[k];
				else continue;
		}
		cout<<endl;
		
	
  }
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