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

why wrong?

Posted by 980616701 at 2009-06-24 17:58:37 on Problem 1503
#include<iostream>
using namespace std;
int main()
{ 
	  int b[200]={0},c[200]={0},l=0;
	  int i,ka,kb,k,o=0;
	  char a1[240],b1[240];
	  gets(a1);ka=strlen(a1); 
	  k=ka;
	  for(i=0;i<ka;i++)c[i]=a1[ka-i-1]-'0';
	  while(1)
	  {
		  l++;
		  gets(b1);
		  if(strcmp(b1,"0")==0)break;
		  if(b1[0]=='0')for(int w=1;w<strlen(b1);w++){if(b1[w-1]=='0'&&b1[w]=='0')o++;}
		  kb=strlen(b1);
		  if(ka>=kb) k=ka;
		  else k=kb;
		  for(i=0;i<kb-o;i++) b[i]=b1[kb-i-1]-'0';
		  for(i=0;i<k;i++)
		  {
			   c[i]=b[i]+c[i];
			   c[i+1]=c[i+1]+c[i]/10;
			   c[i]=c[i]%10;
		  }
		  if(c[k]!=0) k++; 
	  }
	  for(i=k-1;i>=0;i--)cout<<c[i];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