蓝桥杯 基础练习 报时助手 (vip)简单粗暴
代码:
#include<bits/stdc++.h>
using namespace std;
char *trans(int x)
{
if(x==1)
return "one";
else if(x==0)
return "zero";
else if(x==2)
return "two";
else if(x==3)
return "three";
else if(x==4)
return "four";
else if(x==5)
return "five";
else if(x==6)
return "six";
else if(x==7)
return "seven";
else if(x==8)
return "eight";
else if(x==9)
return "nine";
else if(x==10)
return "ten";
else if(x==11)
return "eleven";
else if(x==12)
return "twelve";
else if(x==13)
return "thirteen";
else if(x==14)
return "fourteen";
else if(x==15)
return "fifteen";
else if(x==16)
return "sixteen";
else if(x==17)
return "seventeen";
else if(x==18)
return "eighteen";
else if(x==19)
return "nineteen";
else if(x==20)
return "twenty";
else if(x==30)
return "thirty";
else if(x==40)
return "forty";
else if(x==50)
return "fifty";
else if(x==10)
return "ten";
}
int main()
{
int m,h;
cin>>h>>m;
if(m==0)
{
cout<<trans(h)<<" o'clock";
}
else
{
if(h<=20||h==30||h==40||h==50)
cout<<trans(h)<<" ";
else
{
int a=h%10;
int b=h-a;
cout<<trans(b)<<" "<<trans(a);
}
cout<<" ";
if(m<=20||m==30||m==40||m==50)
cout<<trans(m)<<" ";
else
{
int a=m%10;
int b=m-a;
cout<<trans(b)<<" "<<trans(a);
}
}
return 0;
}