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

注意No和Ok的大小写!我把No写成NO就WA了

Posted by seol at 2004-12-24 18:48:38 on Problem 1350
In Reply To:我也找不出错了,哪位大哥看看还有什么情况不对的~!! Posted by:zxystar at 2004-03-13 10:19:31
> #include<iostream>
> #include<algorithm>
> using namespace std;
> int sub(int &a,int &m){
> 		
> 		int num[4];
> 		num[0]=a%10;
> 		num[1]=(a%100)/10;
> 		num[2]=(a%1000)/100;
> 		num[3]=a/1000;
> 		if((num[0]==num[1])&&(num[1]==num[2])&&(num[2]==num[3]))
> 			return -1;
> 		sort(num,num+4);
> 		int b=num[0]*1000+num[1]*100+num[2]*10+num[3];
> 		a=num[3]*1000+num[2]*100+num[1]*10+num[0];
> 		
> 		if(num[0]==0&&num[2]==num[1]&&num[2]==num[3]){
> 			a=a/10;
> 			
> 		}
> 		int temp=a-b;
> 		cout<<a<<"-"<<b<<"="<<temp<<endl;
> 		 a=temp;
> 		 return 0;
> 		
>  
> }
> 	
> int main(){
> 		
> 		int a,b;
> 		
> 		cin>>a;
> 		while(a!=-1){
> 			if(a>9999){
> 				cout<<"No!!"<<endl;
> 				cin>>a;
> 				continue;
> 			}
> 			int n=1;
> 			cout<<"N="<<a<<":"<<endl;
> 			for(int &m=n;;m++){
> 				b=sub(a,m);
> 				if(b==-1){
> 					cout<<"No!!"<<endl;
> 					break;
> 				}
> 				if(a==0||a==6174){
> 				cout<<"ok!! "<<m<<" times"<<endl;
> 				break;
> 				}
> 			}
> 		cin>>a;	
> 		}
> 		
> }

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