蓝桥杯 1468: [蓝桥杯][基础练习VIP]报时助手
基本思想:
水题,没什么可说的;
关键点:
无;
#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;
}

浙公网安备 33010602011771号