这道题,我看了别人是用取余来解决,但我比较...笨,暴力了一点
Description
给定当前的时间,请用英文的读法将它读出来。
时间用时h和分m表示,在英文的读法中,读一个时间的方法是:
如果m为0,则将时读出来,然后加上“o'clock”,如3:00读作“three o'clock”。
如果m不为0,则将时读出来,然后将分读出来,如5:30读作“five thirty”。
时和分的读法使用的是英文数字的读法,其中0~20读作:
0:zero, 1: one, 2:two, 3:three, 4:four, 5:five, 6:six, 7:seven, 8:eight, 9:nine, 10:ten, 11:eleven, 12:twelve, 13:thirteen, 14:fourteen, 15:fifteen, 16:sixteen, 17:seventeen, 18:eighteen, 19:nineteen, 20:twenty。
30读作thirty,40读作forty,50读作fifty。
对于大于20小于60的数字,首先读整十的数,然后再加上个位数。如31首先读30再加1的读法,读作“thirty one”。
按上面的规则21:54读作“twenty one fifty four”,9:07读作“nine seven”,0:15读作“zero fifteen”。
Input
输入包含两个非负整数h和m,表示时间的时和分。非零的数字前没有前导0。h小于24,m小于60。
Output
输出时间时刻的英文。
Sample Input
0 15
Sample Output
zero fifteen
#include <cstdio> #include <iostream> #include <cmath> #include <string> #include <cstring> #include <algorithm> #include <queue> #include <stack> using namespace std; #define ll long long int main() { int n, m; while(cin >> n >> m) { if(n == 0)printf("zero"); else if(n == 1)printf("one"); else if(n == 2)printf("two"); else if(n == 3)printf("three"); else if(n == 4)printf("four"); else if(n == 5)printf("five"); else if(n == 6)printf("six"); else if(n == 7)printf("seven"); else if(n == 8)printf("eight"); else if(n == 9)printf("nine"); else if(n == 10)printf("ten"); else if(n == 11)printf("eleven"); else if(n == 12)printf("twelve"); else if(n == 13)printf("thirteen"); else if(n == 14)printf("fourteen"); else if(n == 15)printf("fifteen"); else if(n == 16)printf("sixteen"); else if(n == 17)printf("seventeen"); else if(n == 18)printf("eighteen"); else if(n == 19)printf("nineteen"); else if(n == 20)printf("twenty"); else if(n == 21)printf("twenty one"); else if(n == 22)printf("twenty two"); else if(n == 23)printf("twenty three"); printf(" "); if(m == 0)printf("o'clock "); else if(m == 1)printf("one "); else if(m == 2)printf("two "); else if(m == 3)printf("three "); else if(m == 4)printf("four "); else if(m == 5)printf("five "); else if(m == 6)printf("six "); else if(m == 7)printf("seven "); else if(m == 8)printf("eight "); else if(m == 9)printf("nine "); else if(m == 10)printf("ten "); else if(m == 11)printf("eleven "); else if(m == 12)printf("twelve "); else if(m == 13)printf("thirteen "); else if(m == 14)printf("fourteen "); else if(m == 15)printf("fifteen "); else if(m == 16)printf("sixteen "); else if(m == 17)printf("seventeen "); else if(m == 18)printf("eighteen "); else if(m == 19)printf("nineteen "); else if(m == 20)printf("twenty "); else if(m == 21)printf("twenty one "); else if(m == 22)printf("twenty two "); else if(m == 23)printf("twenty three "); else if(m == 24)printf("twenty four "); else if(m == 25)printf("twenty five "); else if(m == 26)printf("twenty six "); else if(m == 27)printf("twenty seven "); else if(m == 28)printf("twenty eight "); else if(m == 29)printf("twenty nine "); else if(m == 30)printf("thirty "); else if(m == 31)printf("thirty one "); else if(m == 32)printf("thirty two "); else if(m == 33)printf("thirty three "); else if(m == 34)printf("thirty four "); else if(m == 35)printf("thirty five "); else if(m == 36)printf("thirty six "); else if(m == 37)printf("thirty seven "); else if(m == 38)printf("thirty eight "); else if(m == 39)printf("thirty nine "); else if(m == 40)printf("forty "); else if(m == 41)printf("forty one "); else if(m == 42)printf("forty two "); else if(m == 43)printf("forty three "); else if(m == 44)printf("forty four "); else if(m == 45)printf("forty five "); else if(m == 46)printf("forty six "); else if(m == 47)printf("forty seven "); else if(m == 48)printf("forty eight "); else if(m == 49)printf("forty nine "); else if(m == 50)printf("fifty "); else if(m == 51)printf("fifty one "); else if(m == 52)printf("fifty two "); else if(m == 53)printf("fifty three "); else if(m == 54)printf("fifty four "); else if(m == 55)printf("fifty five "); else if(m == 56)printf("fifty six "); else if(m == 57)printf("fifty seven "); else if(m == 58)printf("fifty eight "); else if(m == 59)printf("fifty nine "); } return 0; }