'commit'
This commit is contained in:
28
C++专题课程/基础知识/报时助手.cpp
Normal file
28
C++专题课程/基础知识/报时助手.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
#include<bits/stdc++.h>
|
||||
using namespace std;
|
||||
int main() {
|
||||
char a[22][20]= {"zero","one","two","three","four","five","six", "seven","eight" ,"nine" , "ten", "eleven","twelve" , "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen", "twenty",""};
|
||||
char b[5][20]= {"","twenty","thirty","forty","fifty"};
|
||||
int h,m,h1,m1;
|
||||
scanf("%d %d",&h,&m);
|
||||
if(m==0)
|
||||
printf("%s o'clock",a[h]);
|
||||
else {
|
||||
if(m<20) {
|
||||
h1=h/20;
|
||||
h=h%20;
|
||||
if(h==0)h=21;
|
||||
printf("%s %s %s",b[h1],a[h],a[m]);
|
||||
} else {
|
||||
h1=h/20;
|
||||
h=h%20;
|
||||
if(h==0)h=21;
|
||||
m1=m/10-1;
|
||||
m=m%10;
|
||||
printf("%s %s %s %s\n",b[h1],a[h],b[m1],a[m]);
|
||||
}
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user