#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <map>
#include <cctype>
using namespace std;
char res[15];
int main()
{
//freopen("in.txt","r",stdin);
int T;
scanf("%d",&T);
while(T--)
{
scanf("%s",res);
int len=strlen(res);
if(len>=2&&res[len-2]=='1')
{
printf("%sth",res);
}
else
{
if(res[len-1]=='1')
{
printf("%sst",res);
}
else if(res[len-1]=='2')
{
printf("%snd",res);
}
else if(res[len-1]=='3')
{
printf("%srd",res);
}
else
{
printf("%sth",res);
}
}
printf("\n");
}
return 0 ;
}
ZOJ 3487 Ordinal Numbers
最新推荐文章于 2017-02-19 17:10:19 发布