poj 2247 1338指针的滞后性

#include<stdio.h>

#define MIN(a,b) ((a>b)? (b):(a)) 			//宏定义函数

const int MAIX=5850;

int main()
{
	int n;
	int v1,v2,v3,v4;
	int p1,p2,p3,p4;
	int a[MAIX];
	a[1]=1;
	p1=p2=p3=p4=1;
	for(int i=2;i<MAIX;i++)
	{
		v1=a[p1]*2;
		v2=a[p2]*3;
		v3=a[p3]*5;
		v4=a[p4]*7;
		a[i]=MIN(MIN(MIN(v1,v2),v3),v4);
		if(v1==a[i]) p1++;
		if(v2==a[i]) p2++;		//会有相同的 ,所以不能用 if else
		if(v3==a[i]) p3++;
		if(v4==a[i]) p4++;
	}

	while(scanf("%d",&n),n)
	{
		if((n%10==1)&&(n%100!=11))
		printf("The %dst humble number is %d.\n",n,a[n]);
		else if((n%10==2)&&(n%100!=12))
		printf("The %dnd humble number is %d.\n",n,a[n]);
		else if((n%10==3)&&(n%100!=13))
		printf("The %drd humble number is %d.\n",n,a[n]);
		else
		printf("The %dth humble number is %d.\n",n,a[n]);
	}
	return 0;
}



你可能感兴趣的:(poj 2247 1338指针的滞后性)