HzuMRL


私信TA

用户名:1710819057

访问量:11581

签 名:

算法菜鸡萌新

等  级
排  名 442
经  验 4714
参赛次数 7
文章发表 27
年  龄 0
在职情况 学生
学  校 贺州学院
专  业

  自我简介:

解题思路:

注意事项:

参考代码:

#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 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换

万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区