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 1019243657 at 2012-09-22 09:54:44 on Problem 1503
#include<iostream>
#include<string.h>
using namespace std;
int JH(char * a)
{
	int l,i;
	char b;
	l=strlen(a);
   
    for(i=0;i<l/2;i++)
	{
		b=a[i];
		a[i]=a[l-1-i];
        a[l-1-i]=b;
	}
	return 0;
}
int addition(char * a,char * b)
{
  int l1,l2,l,i;
  l1=strlen(a);
  l2=strlen(b);
  l=(l1>l2)?l1:l2;
  for(i=l1;i<l;i++) a[i]='0';
  for(i=l2;i<l;i++) b[i]='0';
  for(i=0;i<l;i++)
  {
    b[i]=b[i]+a[i]-48;
    if(b[i]>=58) 
	{
      b[i]-=10;
      if(b[i+1]>47&&b[i+1]<58)   b[i+1]+=1;
	  else b[i+1]='1';
	}
  }
  return 0;
};
int main ()
{
    char a[100],b[101]="0";
    int l,i,j=0,h=0;
	while(EOF)
	{
    while(1)
	{
      gets(a);
	  h++;
	  if(h>=100)  goto XXX;
      JH(a);
      if(strcmp(a,"0")==0)   break;
      addition(a,b);
	}
    l=strlen(b);
	for(i=l-1;i>=0;i--)
	{
		if(b[i]=='0')  j++;
		else break;
	};
    JH(b);
    for (i=j;i<l;i++)
		cout<<char(b[i])<<flush;
    strcpy(b,"0");
	}
XXX: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