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 lbcharry at 2005-05-19 12:30:55 on Problem 2247
#include<iostream.h>
int min(int a,int b,int c,int d)
{
	int x,y;
	if(a>b) x=b;
	else x=a;
	if(c>d) y=d;
	else y=c;
	if(x>y)return y;
	 return x;
}

int main()
{
	int A[5843];
	int w,q;
	int i,k,l,m,n;
	int num[100];
	int j=0;
	int temp;
	A[0]=0;
	A[1]=1;
	A[2]=2;
	A[3]=3;
	A[4]=4;
	A[5]=5;
	A[6]=6;
	A[7]=7;
	k=4;l=3,m=n=2;
	cin>>num[j];
	for(i=8;i<5843;i++)
	{
		A[i]=min(2*A[k],3*A[l],5*A[m],7*A[n]);
		temp=A[i];
		if(2*A[k]==temp)k++;
		if(3*A[l]==temp)l++;
		if(5*A[m]==temp)m++;
		if(7*A[n]==temp)n++;
	}
	while(num[j++])
	{ 
		cin>>num[j];
	}
	for(i=0;i<j-1;i++)
	{	
		w=num[i]%10;
        q=num[i]%100;
		if(q==11||q==12||q==13)
		{
			cout<<"The "<<num[i]<<"th humble number is "<<A[num[i]]<<"."<<endl;
			continue;
		}    
	switch(w)
		{
		case 1:	cout<<"The "<<num[i]<<"st humble number is "<<A[num[i]]<<"."<<endl;
			break;
		case 2:	cout<<"The "<<num[i]<<"nd humble number is "<<A[num[i]]<<"."<<endl;
			break;
		case 3:	cout<<"The "<<num[i]<<"rd humble number is "<<A[num[i]]<<"."<<endl;
			break;
		default:cout<<"The "<<num[i]<<"th humble number is "<<A[num[i]]<<"."<<endl;
			break;
		}
	}
	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