SK


私信TA

用户名:1973231998

访问量:18565

签 名:

成功只是一时的,失败才是主旋律,笑着面对失败是主要的。

等  级
排  名 262
经  验 5693
参赛次数 0
文章发表 59
年  龄 0
在职情况 学生
学  校 *
专  业

  自我简介:

解题思路:

注意事项:输入中间有空格,思路很简单,分情况就行了,然后直接读取相应数字的字符串。

参考代码:

#include<bits/stdc++.h>
using namespace std;
char t[30][10] = { "zero","one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen","twenty","thirty","forty","fifty","sixty" };
int main()
{
	int h,m;
	scanf("%d %2d", &h, &m);
	int temh = 0;
	int tem = 0;
	if (m == 0) cout <<t[h]<<" "<<"o'clock"<<endl;
	else
	{
		if (h > 20)
		{
			h = h % 10;
			cout << "twenty" << " " << t[h];
		}
		else cout << t[h];
		if (m > 20)
		{
			tem = (m / 10)*10;
			if (tem == 30) tem = 21;
			else if (tem == 40) tem = 22;
			else if (tem == 50) tem = 23;
			else if (tem == 60) tem = 24;
			m = m % 10;
			cout <<" "<<t[tem];
			if(m!=0)cout <<" "<< t[m];
		}
		else
			cout << " " << t[m];
	}
	
}


 

0.0分

2 人评分

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

编程语言转换万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区