ZOJ 3487Ordinal Numbers
来源:互联网 发布:淘宝上的宠物狗能买吗 编辑:程序博客网 时间:2024/05/18 22:42
- 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.
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.
For each test case, output the corresponding ordinal number.
512341024
1st2nd3rd4th1024th
References
- http://en.wikipedia.org/wiki/Names_of_numbers_in_English
- http://en.wikipedia.org/wiki/Ordinal_number_(linguistics)
简单题
#include<map>#include<cmath> #include<queue> #include<string>#include<vector>#include<cstdio> #include<cstring> #include<algorithm> using namespace std;#define ms(x,y) memset(x,y,sizeof(x)) #define rep(i,j,k) for(int i=j;i<=k;i++) #define per(i,j,k) for(int i=j;i>=k;i--) #define loop(i,j,k) for (int i=j;i!=-1;i=k[i]) #define inone(x) scanf("%d",&x) #define intwo(x,y) scanf("%d%d",&x,&y) #define inthr(x,y,z) scanf("%d%d%d",&x,&y,&z) typedef long long LL;const int low(int x) { return x&-x; }const int INF = 0x7FFFFFFF;const int mod = 1e9 + 7;const int N = 1e5 + 10;int T, n;char s[4][4] = { "th","st","nd","rd" };int main(){for (inone(T); T--;){inone(n);printf("%d", n);if (n / 10 % 10 != 1 && n % 10 && n % 10 < 4) puts(s[n % 10]);else puts(s[0]); }return 0;}
0 0
- 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
- ZOJ - 3487 Ordinal Numbers
- ZOJ 3487Ordinal Numbers
- ZOJ 3487A - Ordinal Numbers
- ZOJ Problem Set - 3487||Ordinal Numbers
- ZOJ 3487Ordinal Numbers(模拟)
- Ordinal Numbers
- A Ordinal Numbers
- ZOJ3487-Ordinal Numbers
- 英文序數寫法與唸法 Ordinal Numbers(轉載)
- 省赛热身赛之Ordinal Numbers
- javascript 中的 undefined 总结
- JavaSE_24th_接口
- 设计模式—依赖倒转原则
- N26--第十四次博客作业
- Java远程调用(二)实现一个简单的服务框架
- ZOJ 3487Ordinal Numbers
- C 练习实例11 斐波那契数列
- 启动hdfs文件系统后,Browse the filesystem链接打不开
- Android网络编程之——文件断点下载(暂停/继续/重新下载)
- 数据库简易帮助包
- java创建对象的几种方法
- Linux多线程编程(二)-----同步与互斥
- wireshark浅析tcp三次握手
- 图像处理算法(一)---图像常用格式