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 envaitenet at 2010-08-26 20:49:39 on Problem 2498
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	int n,b[10],i,j,k,t,len,x,z;
	char d[10];
	scanf("%d",&n);
	for(i=1;i<=4;i++)
	{
		int sum=0,s;
		scanf("%s",d);
		len=strlen(d);
		for(j=len-1;j>=0;j--)
		{
			if(d[j]>='0'&&d[j]<='9')
			{
				b[j]=d[j]-'0';
				if((len-j)%3==1)
					sum+=b[j]*9;
				if((len-j)%3==2)
					sum+=b[j]*3;
				if((len-j)%3==0)
					sum+=b[j]*7;
			}
			else 
			{
				t=j;
				if((len-j)%3==1)
					z=9;
				if((len-j)%3==2)
					z=3;
				if((len-j)%3==0)
					z=7;
			}
		}
		for(x=0;x<=9;x++)
		{					
			s=sum;
			s+=x*z;
			if(s%10==0)
				break;
		}
		cout<<"Scenario #"<<i<<":"<<endl;
		for(k=0;k<len;k++)
		{
			if(k==t)
				printf("%d",x);
			else
				printf("%d",b[k]);
		}
		cout<<endl<<endl<<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