iiiii_iiiii
大爱C++!
2019-10-19 23:15

求助CB 大佬快来!一个小问题

  • c++

//输入数字显示其英文
#include
using namespace std;
int main()
{
int a,b,c;
cout<<"请输入两位数:"< cin>>a;
cout<<"其英文为:"<<endl;
b=a/10;
c=a%10;
if(a==11)
cout<<"eleven"<<endl;
if(a==12)
cout<<"twelve"<<endl;
if(a==13)
cout<<"thirteen"<<endl;
if(a==14)
cout<<"fourteen"<<endl;
if(a==15)
cout<<"fifteen"<<endl;
if(a==16)
cout<<"sixteen"<<endl;
if(a==17)
cout<<"seventeen"<<endl;
if(a==18)
cout<<"eighteen"<<endl;
if(a==19)
cout<<"nineteen"<<endl;
switch(b)
{
case 1:
cout<<"ten";break;
case 2:
cout<<"twenty";break;
case 3:
cout<<"thirty";break;
case 4:
cout<<"forty";break;
case 5:
cout<<"fifty";break;
case 6:
cout<<"sixty";break;
case 7:
cout<<"seventy";break;
case 8:
cout<<"eighty";break;
case 9:
cout<<"ninety";break;
}
switch(c)
{
case 1:
cout<<"-one"<<endl;break;
case 2:
cout<<"-two"<<endl;break;
case 3:
cout<<"-three"<<endl;break;
case 4:
cout<<"-four"<<endl;break;
case 5:
cout<<"-five"<<endl;break;
case 6:
cout<<"-six"<<endl;break;
case 7:
cout<<"-seven"<<endl;break;
case 8:
cout<<"-eight"<<endl;break;
case 9:
cout<<"-nine"<<endl;break;
}
return 0;
}


```就是我想请问我输入11 得到的结果是eleven ten-one;如何避免后一个数据的出现?就是在我执行完if后直接结束程序 求解答
谢谢!![图片说明](https://img-ask.csdn.net/upload/201910/19/1571498095_754425.png)
  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

1条回答

为你推荐