基本思想:
水题,没什么可说的;
关键点:
无;
#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; }
原文:https://www.cnblogs.com/songlinxuan/p/12287051.html