- 1、本文档共4页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
经典C试题
Ordinal Numbers
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
5
1
2
3
4
1024
Sample Output
1st
2nd
3rd
4th
1024th
解析
此题属简单题,题意是给整数,输出这个整数英语的序数形式。赛场上貌似2分钟就有队伍做出此题了,我们的队伍大约在第6分钟做出此题,很快。
要求有两个,一个是十位为1的,后面统一th;另一个是十位非1的,1,2,3有变化。
C++样例代码
#include iostream
using namespace std;
int main(){
int T,n,x,y;
cin T;
while(T--){
cin n;
x = n % 10; //个位数字
y = n / 10 % 10; //十位数字
cout n;
if(x == 1 y != 1) cout st;
else if(x == 2 y != 1) cout nd;
else if(x == 3 y != 1) cout rd;
else cout th;
cout endl;
}
return 0;
}
Conic Section
The conic sections are the nondegenerate curves generated by the intersections of a plane with one or two nappes of a cone. For a plane perpendicular to the axis of the cone, a circle is produced. For a plane that is not perpendicular to the axis and that intersects only a single nappe, the curve produced is either an ellipse or a parabola. The curve produced by a plane intersecting both nappes is a hyperbola.
conic section equation circle x2
文档评论(0)