cc王


私信TA

用户名:uq_86486662518

访问量:2061

签 名:

吉利给给给!

等  级
排  名 839
经  验 3495
参赛次数 10
文章发表 6
年  龄 20
在职情况 学生
学  校 盐城师范学院
专  业 数字媒体技术

  自我简介:

解题思路:
先将构造20以内的英文字符串,再构造30、40、50的英文字符串,然后分解时和分输出。

注意事项:
整点(即分为0)输出o'clock!
参考代码:

#include<iostream>
#include<string.h>
using namespace std;
char a[25][15]={"zero ","one ","two ","three ","four ","five ","six ","seven ","eight ","nine ","ten ","eleven ","twelve ","thirteen ","fourteen ","fifteen ","sixteen ","seventeen ","eighteen ","nineteen ","twenty "};
char b[6][10]={"","","twenty ","thirty ","forty ","fifty "};
void print(int n)
{
	if(n<20){
		cout<<a[n];
	}
	else if(n%10==0){
		cout<<b[n/10];
	}
	else
	{
		cout<<b[n/10];
		cout<<a[n%10];
	}
 } 
int main()
{
	int h,min;
	cin>>h>>min;
	if(min==0) {
		print(h);
		cout<<"o'clock";
	}
	else{
	print(h);
	print(min);	
	}
	
	return 0;
}


 

0.0分

1 人评分

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

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

代码解释器

代码纠错

SQL生成与解释

  评论区