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

为什么Output Limit Exceed??简直不能忍!!高手给看一下输出行吗?谢了。

Posted by mine at 2004-12-18 18:07:43 on Problem 1350
#include <stdio.h>
int fig[4];
void arrange(int num) {
	int i,j,temp;
	fig[0]=num/1000;
	fig[1]=(num-fig[0]*1000)/100;
	fig[2]=(num-fig[0]*1000-fig[1]*100)/10;
	fig[3]=num-fig[0]*1000-fig[1]*100-fig[2]*10;
	for(i=0;i<=3;i++) {
		for(j=1;j<=3-i;j++) {
			if(fig[j]<fig[j-1]) {
				temp=fig[j];
				fig[j]=fig[j-1];
				fig[j-1]=temp;
			}
		}
	}
}
int biggest(int num) {
	int big;
	arrange(num);
	if(num>=100&&num<=999)
		big=fig[3]*100+fig[2]*10+fig[1];
	else if(num>=10&&num<=99)
		big=fig[3]*10+fig[2];
		else if(num>=1&&num<=9)
			big=fig[3];
			else 
				big=fig[3]*1000+fig[2]*100+fig[1]*10+fig[0];
	return big;
}
int smallest(int num) {
	int small;
	arrange(num);
	small=fig[0]*1000+fig[1]*100+fig[2]*10+fig[3];
	return small;
}
void main() {
	int n[300],big[300],small[300],flag[300],i,temp[300];
	for(i=0;;i++) {
		scanf("%d",&n[i]);
		temp[i]=n[i];
		if(n[i]==-1)
			break;
	}
	for(i=0;;i++) {
		if(n[i]==-1) break;
		if(n[i]%1111==0) {
			printf("N=%d:\n",temp[i]);
			printf("No!!\n");
		}
		else {
			printf("N=%d:\n",temp[i]);
			for(flag[i]=1;;flag[i]++) {
				big[i]=biggest(n[i]);
				small[i]=smallest(n[i]);
				n[i]=big[i]-small[i];
				printf("%d-%d=%d\n",big[i],small[i],n[i]);
				if(n[i]==6174||n[i]==0) break;
			}
			printf("Ok!! %d times\n",flag[i]);
		}
	}
}

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