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

我编的程序为什么总在VC可运行,却在poj上WA

Posted by huangjing1987 at 2009-08-24 20:37:54 on Problem 1503
#include<iostream>
#include<string>
using std::string;
using std::cin;
using std::cout;
int a[105]={0};
void f(int v)
{
	a[v]++;
	if(a[v]>=10)
	{
		a[v]=a[v]%10;
		v++;
		f(v);
	}
}
void add(char *p)
{		
	int w=0,u=0,u1=0;
	u1=strlen(p)-1;
	while(u!=strlen(p))
	{
		w=int(p[u1]-'0');
		a[u]=w+a[u];
		if(a[u]>=10)
		{
			a[u]=a[u]%10;
			f(u+1);
		}
		u++;
		u1--;

	}
}
int main()
{
	int j=0,j1=0,y=105;
	char l[200],*p="0";
	cin>>l;
	j=strlen(l)-1;
	while(j!=-1)
	{
		a[j1]=int(l[j]-'0');
		j--;
		j1++;
	}
	while(strcmp(p,l)!=0)
	{
		cin>>l;
		add(l);
	}
	while(a[y]==0)
	{
		--y;
	}
	for(int s=y;s>=0;s--)
	{
		cout<<a[s];
	}
	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