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

怎么老是Runtime error!!

Posted by jiangyang008 at 2007-08-18 06:32:05 on Problem 2247
#include <stdio.h>

int main(){
	int n, humble[5843];
	int l2=0, l3=0, l5=0, l7=0, i=0, t1, t2;
	humble[i]=1;
	while(i<5844)
	{
		t1 = humble[l2] * 2 > humble[l3] * 3 ? humble[l3] * 3 : humble[l2] * 2;
		t2 = humble[l5] * 5 > humble[l7] * 7 ? humble[l7] * 7 : humble[l5] * 5;
		humble[++i] = t1 > t2 ? t2 : t1;
		if((humble[l2] * 2) == humble[i]) l2++;
		if((humble[l3] * 3) == humble[i]) l3++;
		if((humble[l5] * 5) == humble[i]) l5++;
		if((humble[l7] * 7) == humble[i]) l7++;
	}
	while(1)
	{
		scanf("%d",&n);
		if ((n < 1) || (n > 5842)) break;
		else if ((n % 10) == 1) {
			if ((n % 100) == 11)
				printf("The %dth humble number is %d.\n", n, humble[n-1]);
			else printf("The %dst humble number is %d.\n", n, humble[n-1]);
		}
		else if ((n % 10) == 2) {
			if ((n % 100) == 12)
				printf("The %dth humble number is %d.\n", n, humble[n-1]);
			else printf("The %dnd humble number is %d.\n", n, humble[n-1]);
		}
		else if ((n % 10) == 3) {
			if ((n % 100) == 13)
				printf("The %dth humble number is %d.\n", n, humble[n-1]);
			else printf("The %drd humble number is %d.\n", n, humble[n-1]);
		}
		else 
			printf("The %dth humble number is %d.\n", n, humble[n-1]);	
	}
	printf("yun!\n");
	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