首页 > 其他 > 详细

蓝桥杯 1468: [蓝桥杯][基础练习VIP]报时助手

时间:2020-02-09 15:30:47      阅读:92      评论:0      收藏:0      [点我收藏+]

基本思想:

水题,没什么可说的;

 

关键点:

无;

 

#include<iostream>
#include<stdlib.h>
#include<stdio.h>
#include<vector> 
#include<string>
#include<math.h>
#include<algorithm>
#include<cstring>
using namespace std;

vector<string>time_1 = {"zero","one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen","twenty"};
vector<string>time_2 = { "twenty","thirty","forty","fifty" };

string func(int n) {
	if (n <= 20)
		return time_1[n];
	int m = n % 10;
	n = n / 10-2;
	string s = time_2[n];
	if (m != 0)
		s += ‘ ‘ + time_1[m];
	return s;
}

int main(){
	int h, m;
	cin >> h >> m;
	if (m == 0)
		cout << func(h) << " o‘clock";
	else
		cout << func(h) << " " << func(m);
	return 0;
}

  

蓝桥杯 1468: [蓝桥杯][基础练习VIP]报时助手

原文:https://www.cnblogs.com/songlinxuan/p/12287051.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!