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 00448322 at 2005-04-28 19:12:18 on Problem 1350
In Reply To:为什么Output Limit Exceed??简直不能忍!!高手给看一下输出行吗?谢了 Posted by:00448322 at 2005-04-28 19:10:15
> #include <iostream.h>
> #include <stdlib.h>
> #include <string.h>
> 
> int cmp1(const void *a,const void *b)
> {
> 	return *(char*)a-*(char*)b;
> }
> 
> int cmp2(const void *a,const void *b)
> {
> 	return -*(char*)a+*(char*)b;
> }
> 
> void main()
> {
> 	int count;
> 	int num;
> 	char num1[5],num2[5];
> 	int max,min;
> 	while(1)
> 	{
> 		count=0;
> 		cin>>num;
> 		if(num==-1)
> 			break;
> 		cout<<"N="<<num<<":"<<endl;
> 		if(num%1111==0 || num>9999 || num<1000)
> 		{
> 			cout<<"No!!"<<endl;
> 			continue;
> 		}
> 		itoa(num,num1,10);
> 		itoa(num,num2,10);
> 		while(1)
> 		{
> 			count++;
> 			qsort(num1,strlen(num1),sizeof(char),cmp1);
> 			qsort(num2,strlen(num2),sizeof(char),cmp2);
> 			min=atoi(num1);
> 			max=atoi(num2);
> 			cout<<max<<"-"<<min<<"="<<max-min<<endl;
> 			if(max-min==0 || max-min==6174)
> 			{
> 				cout<<"Ok!! "<<count<<" times"<<endl;
> 				break;
> 			}
> 			itoa(max-min,num1,10);
> 			itoa(max-min,num2,10);
> 		}
> 	}
> }
> 
> 

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