题意:为第几加后缀。
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3487
——>>直接模拟。
#include <iostream>
using namespace std;
int main()
{
int T, n;
cin>>T;
while(T--)
{
cin>>n;
int tens = n % 100 / 10;
int ones = n % 10;
cout<<n;
if(tens != 1)
{
switch(ones)
{
case 1:
{
cout<<"st"<<endl;
break;
}
case 2:
{
cout<<"nd"<<endl;
break;
}
case 3:
{
cout<<"rd"<<endl;
break;
}
default:
{
cout<<"th"<<endl;
break;
}
}
}
else cout<<"th"<<endl;
}
return 0;
}