HzuMRL


私信TA

用户名:1710819057

访问量:12038

签 名:

算法菜鸡萌新

等  级
排  名 459
经  验 4762
参赛次数 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 人评分

  评论区

  • «
  • »