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 o0Fancy0o at 2008-10-17 23:56:27 on Problem 2719 and last updated at 2008-10-18 00:00:03
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
	int n,nn,N[9],sum,i,*p;
	for (i=0;i<9;i++)
	{
		N[i]=0;
	}
	sum=0;
	cin>>n;
	while (n!=0)
	{
		nn=n;
		p=&N[8];
		for (i=0;i<9;i++)
		{
			*p=n%10;
			n/=10;
			p--;
		}
		p=N;
		for (i=0;i<9;i++)
		{
			if (*p>=5)
			{
				(*p)--;
				sum+=*p*pow(float (9),int (8-i));
			}
			else
			{
				sum+=*p*pow(float (9),int (8-i));
			}
			p++;
		}
		cout<<nn<<": "<<sum<<endl;
		sum=0;
		cin>>n;
	}
	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