Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
为什么答案错了!!高手门来帮忙看看#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator