解题思路:
注意事项:
参考代码:
#include<iostream>
using namespace std;
int main()
{
int n,m;
cin>>n>>m;
string str1[] = {"zero","one","two","three","four","five","six","seven","eight",
"nine","ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen",
"seventeen","eighteen","nineteen","twenty"};
string str2[] ={"thirty","forty","fifty"};
if(n>=0&&n<=20)
{
if(m==0)
{
cout<<str1[n]<<" o'clock"<<endl;
}
else if(m>0&&m<=20)
{
cout<<str1[n]<<" "<<str1[m]<<endl;
}
else if(m>=30&&m<40)
{
if(m==30)
{
cout<<str1[n]<<" "<<str2[0]<<endl;
}
else
{
cout<<str1[n]<<" "<<str2[0]<<" "<<str1[m%10]<<endl;
}
}
else if(m>=40&&m<50)
{
if(m==40)
{
cout<<str1[n]<<" "<<str2[1]<<endl;
}
else
{
cout<<str1[n]<<" "<<str2[1]<<" "<<str1[m%10]<<endl;
}
}
else if(m>=50&&m<60)
{
if(m==50)
{
cout<<str1[n]<<" "<<str2[2]<<endl;
}
else
{
cout<<str1[n]<<" "<<str2[2]<<" "<<str1[m%10]<<endl;
}
}
}
else if(n>20&&n<24)
{
if(m==0)
{
cout<<str1[20]<<" "<<str1[n%10]<<" o'clock"<<endl;
}
else if(m>0&&m<=20)
{
cout<<str1[20]<<" "<<str1[n%10]<<str1[m]<<endl;
}
else if(m>=30&&m<40)
{
if(m==30)
{
cout<<str1[20]<<" "<<str1[n%10]<<" "<<str2[0]<<endl;
}
else
{
cout<<str1[20]<<" "<<str1[n%10]<<" "<<str2[0]<<" "<<str1[m%10]<<endl;
}
}
else if(m>=40&&m<50)
{
if(m==40)
{
cout<<str1[20]<<" "<<str1[n%10]<<" "<<str2[1]<<endl;
}
else
{
cout<<str1[20]<<" "<<str1[n%10]<<" "<<str2[1]<<" "<<str1[m%10]<<endl;
}
}
else if(m>=50&&m<60)
{
if(m==50)
{
cout<<str1[20]<<" "<<str1[n%10]<<" "<<str2[2]<<endl;
}
else
{
cout<<str1[20]<<" "<<str1[n%10]<<" "<<str2[2]<<" "<<str1[m%10]<<endl;
}
}
}
else
{
return 0;
}
return 0;
}
0.0分
0 人评分
C语言程序设计教程(第三版)课后习题8.6 (C语言代码)浏览:609 |
C语言程序设计教程(第三版)课后习题6.4 (C语言代码)浏览:623 |
C语言程序设计教程(第三版)课后习题7.1 (C语言代码)浏览:761 |
C语言程序设计教程(第三版)课后习题8.8 (C语言代码)浏览:1482 |
IP判断 (C语言描述,蓝桥杯)浏览:1118 |
1157题解浏览:769 |
C语言程序设计教程(第三版)课后习题10.1 (C语言代码)浏览:585 |
1024题解浏览:879 |
A+B for Input-Output Practice (V) (C语言代码)浏览:497 |
【亲和数】 (C语言代码)浏览:628 |