View Code of Problem 447

#include<stdio.h>
int main()
{
	int t,n,i,k,a,b;
	while(scanf("%d",&t)!=EOF)
	{
		if(t>0&&t<=1000)
		{
			for(k=0;k<t;k++)
			{
				scanf("%d",&n);
				if(n>=0&&n<1000000000)
				{
					a=n%10;
					b=(n/10)%10;
					if(b==1)
					{
						printf("%dth\n",n);
					}
					else
					{
						if(a==1)
							printf("%dst\n",n);
						else if(a==2)
							printf("%dnd\n",n);
						else if(a==3)
							printf("%drd\n",n);
						else
							printf("%dth\n",n);
					}
				}
			}
		}
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 447