Problem 45 What Time Is It
来源:互联网 发布:林徽因鲁迅知乎 编辑:程序博客网 时间:2024/05/16 05:50
这个问题是要求把数字形式的时间转换成文字形式的。所有的regulation都给出了,编码的时候小心一点考虑全面就是了。
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main(){
string exp;
int hr, min;
char dump;
ifstream fin("clock.in");
fin>>hr>>dump>>min;
string hour[] = {"one", "two", "three", "four",
"five","six", "seven", "eight",
"nine","ten", "eleven","twelve"};
string minute[] = {" o'clock", "one", "two", "three",
"four", "five","six", "seven",
"eight", "nine", "ten", "eleven",
"twelve", "thirteen", "fourteen",
"fifteen","sixteen", "seventeen",
"eighteen","nineteen"};
string key[] = {"twenty", "thirty", "forty"};
switch(min){
case 0:
exp = hour[hr - 1] + minute[min];
break;
case 15:
exp = "quarter past " + hour[hr - 1];
break;
case 30:
exp = hour[hr - 1] + " thirty";
break;
case 45:
exp = "quarter to " + hour[hr % 12];
break;
default:
if(min < 20) exp = hour[hr - 1] + " " + minute[min];
else if(min > 45)
exp = minute[60 - min] + " to " + hour[hr % 12];
else{
exp = hour[hr - 1] + " " + key[min / 10 - 2];
if(min % 10) exp = exp + "-" + minute[min % 10];
}
break;
}
// ASCII code: 'A' = 65, 'a' = 97
exp[0] = exp[0] - (97 - 65);
ofstream fout("clock.out");
fout<<exp<<endl;
}
- Problem 45 What Time Is It
- what time is it?
- poj1676 What time is it?
- Poj 1676 What time is it?
- poj 1676 What time is it?
- poj 1676-What time is it?
- poj 1676 What time is it?
- POJ 1676 What time is it? 笔记
- poj 1676 What time is it?(经典模拟)
- What is time meaning......
- what is time
- what is Time Management?
- Maven... What is it?
- what fuck it is
- What is aliasing and what causes it?
- HDU2133:What day is it
- OpenStack, What it really is?
- What day is it 2133
- 葛洪义《法律与理性》反法治化思维解析
- 有关傅立叶变化的资料 [来自网络搜索]
- 实验改变人类:震撼世界的十大科学实验- -
- 了解Java学习过程---查了N多别人的经验总结
- Problem 24 Barn Repair
- Problem 45 What Time Is It
- 磁盘清理程序运行非常慢的解决办法
- 在Sun-Java-System/Application-Server上部署应用(1)
- ShellExecute的功能
- 如何防止网页Demo被那些赖账的客户盗用
- 游戏机器人(2)
- 游戏机器人(3)
- 几乎融入所有新技术的精确制导武器
- 重新回到了DOS时代的感觉(一个IP地址切换的程序)