0点1分0秒是每天的第61秒; 1点0分0秒是每天的第3601秒; 23点59分59秒是每天的第86400秒。
你的任务是编写一个程序,把每天的第n秒转换成具体的24小时制时间(从00:00:00到23:59:59)。
Input
输入为若干整数n,表示每天的第n秒,1<=n<=86400,当输入n为0时表示输入结束。
Output
每行输出一个第n秒对应的具体时间,格式为“hh:mm:ss”。时、分、秒各占2位,不足两位要补0,如0点0分0秒为“00:00:00”。
Sample Input
1 2 61 3600 9999 86400 0
Sample Output
00:00:00 00:00:01 00:01:00 00:59:59 02:46:38 23:59:59
#include
int n,a,b,c; for(;;) {
scanf(\
}
if(n==0) {
break; } n=n-1; a=n/3600;
b=(n600)/60; c=n-3600*a-60*b;
printf(\}
1455 Problem D: 一天中的第几秒
Time Limit: 1 Sec Memory Limit: 2 MB
Submit: 2085 Solved: 1429 [Submit][Status][Web Board]
Description
一天24小时,每小时60分钟,每分钟60秒。一天共有86400秒。 0点0分0秒是每天的第1秒; 0点0分1秒是每天的第2秒; 0点1分0秒是每天的第61秒; 1点0分0秒是每天的第3601秒; 23点59分59秒是每天的第86400秒。
你的任务是编写一个程序,计算出一个24小时制的时间(从00:00:00到23:59:59)是这一天的第几秒?
Input
每行输入24小时制的时间,至EOF结束。
时间的格式为“hh:mm:ss”,时、分、秒各占2位,不足两位的有前缀0,如0点0分0秒为“00:00:00”。
输入的时间均满足0<=hh<23,0<=mm,ss<=59。
Output
每行输出为对应输入行的计算结果,仅为一个整数n,表示输入的时间是这一天的第n秒。
Sample Input
00:00:00 00:00:01 00:01:00 00:59:59 02:46:38 23:59:59
Sample Output
1 2 61 3600 9999 86400
#include
int a,b,c,n;
while(scanf(\ {n=a*3600+b*60+c+1; printf(\ } }
1098 Problem E: 序数的后缀
Time Limit: 1 Sec Memory Limit: 2 MB
Submit: 4244 Solved: 2289 [Submit][Status][Web Board]
Description
英文中经常用阿拉伯数字加上字母后缀表示“第几“这样的序数词。比如,”第10次会面“通常写成”10th meeting“。
后缀来源于英文的序数词:第1的英文是first,写成”1st?;第2的英文是second,写成“2nd”;第3的英文是third,写成“3rd”,第4是fourth,写成“4th”,以后的数字都加“th”。 在这里规定,所有后缀为1的数字都写成“st”结尾,后缀为2的数字写成“nd”结尾,后缀为3的英文写成“rd”结尾,其他的写成“th”结尾。
Input
输入为多个很小的正整数,当输入为0时表示输入结束。
Output
输出为多行,每行对应一个输入数字的序数表示。
Sample Input
1 2 3 4 5 10 11 12 13 14 0
Sample Output
1st 2nd 3rd 4th 5th 10th 11st 12nd 13rd 14th
HINT
用switch语句似乎更容易些。
#include
scanf(\if(n==0) {
break; } if(n<=10) {
if(n==1) {
}
}
printf(\ }
else if(n==2) {
printf(\ }
else if(n==3) {
printf(\ }
else printf(\} else {
m=n; if(m==1) {
printf(\ }
else if(m==2) {
printf(\ }
else if(m==3) {
printf(\ }
else printf(\}