qtL0ng


私信TA

用户名:qtL0ng

访问量:4374

签 名:

等  级
排  名 6103
经  验 1403
参赛次数 0
文章发表 33
年  龄 0
在职情况 学生
学  校
专  业

  自我简介:

参考代码:

#include<iostream>
#include<string>
using namespace std;

int main()
{
	int h, m;
	int h1, m1;
	cin >> h >> m;
	string time[21] = { "zero","one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen","twenty" };
	if (m == 0)
		h <= 20 ? cout << time[h] << " o'clock" << endl : cout << "twenty " << time[h % 20] << " o'clock" << endl;
	else
	{
		h <= 20 ? cout << time[h] : cout << "twenty " << time[h % 20];
		if (m <= 20)
			cout << " " << time[m] << endl;
		else {
			switch (m/10)
			{
			case 2:cout << " twenty " << time[m % 10] << endl;break;
			case 3:cout << " thirty " << time[m % 10] << endl;break;
			case 4:cout << " forty " << time[m % 10] << endl;break;
			case 5:cout << " fifty " << time[m % 10] << endl;break;
			default:
				break;
			}
		}
	}
	return 0;
}


 

0.0分

0 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换

万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区