解题思路:
注意事项:
参考代码:
#include <bits/stdc++.h>
using namespace std;
string ans[100]={"zero","one","two","three","four","five","six","seven","eight"
,"nine","ten","eleven","twelve","thirteen","fourteen","fifteen"
,"sixteen","seventeen","eighteen","nineteen","twenty"};
string bns[100]={"0","thirty","forty","fifty"};
int main()
{
int h,m;
while(cin>>h>>m)
{
if(m==0)
{
if(h!=0)
cout<<h<<" o'clock"<<endl;
else
cout<<ans[h]<<" o'clock"<<endl;
}
else
{
if(h<=20)
{
cout<<ans[h]<<" ";
}
if(h>20&&h<30)
{
cout<<"twenty "<<ans[h%10]<<" ";
}
if(h>=30)
{
cout<<bns[(h-20)/10]<<" "<<ans[h%10]<<" ";
}
if(m<=20)
{
cout<<ans[m]<<endl;
}
if(m>20&&m<30)
{
cout<<"twenty "<<ans[m%10]<<endl;
}
if(m>=30)
{
cout<<bns[(m-20)/10]<<" "<<ans[m%10]<<" ";
}
}
}
return 0;
}
0.0分
0 人评分