Ordinal Numbers
来源:互联网 发布:java poi 合并单元格 编辑:程序博客网 时间:2024/05/29 09:42
Description
Ordinal numbers refer to a position in a series. Common ordinals include zeroth, first, second, third, fourth and so on. Ordinals are not often written in words, they are written using digits and letters. An ordinal indicator is a sign adjacent to a numeral denoting that it is an ordinal number, rather than a cardinal number. In English, the suffixes -st (e.g. 21st), -nd (e.g. 22nd), -rd (e.g. 23rd), and -th (e.g. 24th) are used. The rules are as follows:
- If the tens digit of a number is 1, then write "th" after the number. For example: 13th, 19th, 112th, 9311th.
- If the tens digit is not equal to 1, then use "st" if the units digit is 1, "nd" if the units digit is 2, "rd" if the units digit is 3, and "th" otherwise: For example: 2nd, 7th, 20th, 23rd, 52nd, 135th, 301st.
Input
There are multiple test cases. The first line of input is an integer T ≈ 1000 indicating the number of test cases.
Each test case consists of a cardinal number 0 ≤ n < 1,000,000,000.
Output
For each test case, output the corresponding ordinal number.
Sample Input
512341024
Sample Output
1st2nd3rd4th1024th
简单易懂,废话不多说
#include<iostream>using namespace std;int main(){int t;cin>>t;while(t--){int num;cin>>num;if(num%10==1&&(num-11)%100!=0)cout<<num<<"st"<<endl;else if(num%10==2&&(num-12)%100!=0)cout<<num<<"nd"<<endl;else if(num%10==3&&(num-13)%100!=0)cout<<num<<"rd"<<endl;elsecout<<num<<"th"<<endl;}return 0;}
0 0
- Ordinal Numbers
- A Ordinal Numbers
- zoj 3487 Ordinal Numbers
- ZOJ 3487 Ordinal Numbers
- zoj 3487 Ordinal Numbers
- zoj - 3487 - Ordinal Numbers
- ZOJ 3487 Ordinal Numbers
- ZOJ 3487 Ordinal Numbers
- zoj 3487 Ordinal Numbers
- ZOJ 3487 Ordinal Numbers
- ZOJ3487-Ordinal Numbers
- ZOJ - 3487 Ordinal Numbers
- ZOJ 3487Ordinal Numbers
- 英文序數寫法與唸法 Ordinal Numbers(轉載)
- ZOJ 3487A - Ordinal Numbers
- 省赛热身赛之Ordinal Numbers
- Input English Ordinal Numbers in LaTeX
- ZOJ Problem Set - 3487||Ordinal Numbers
- Oracle 常用dump命令【转自】dave
- OCM_Session8_2_Step-by-Step Instructions for Creating a Physical Standby Database
- 第四周作业-键盘输入数据 和 数据类型
- 第3周作业-循环与判断语句
- 小爬虫系列
- Ordinal Numbers
- android AlertDialog自定义布局文件
- 义 unsigned char *pImage;报错错误: expected expression before ‘unsigned’
- jni的使用
- python特性介绍
- js跨域问题
- 杀毒软件测评--争鸣
- 官方论坛的帖子 How about use "armeabi-v7a" as default ABI on Android for template? ABI 是啥?
- u盘文件打不开了如何恢复