打印号码名称 [英] print name of number

查看:125
本文介绍了打印号码名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请帮助我,我想用C ++语言编写如下程序.插入20到90之间的数字,并使用切换短语打印其名称.

please help me ,I want to write a program as follows in C++ language .Insert a number from 20 to 90 and print his name by using the Switch phrase.

推荐答案

如果您必须在作业上作弊",则至少应以半匿名的方式进行. :)

使用带有合适搜索词的搜索引擎.我不知道,例如 c ++到单词的数字之类的东西.
If you must ''cheat'' on your homework then at least do it in a semi-anonymous way. :)

Use a search engine with a suitable search term. I don''t know, something like c++ number to words, or similar.


首先,将给定的数字分成十位数和一个. (例如,如果您的电话号码是23,int tens = 2;int ones = 3;.)您可以使用模运算符以编程方式完成此操作.

接下来,使用switch语句打印十位数的名称.
First, separate your given number in to tens and ones. (e.g. if your number is 23, int tens = 2; and int ones = 3;.) You can use the modulus operator to accomplish this programmatically.

Next, use a switch statement to print the name of the tens digit.
switch( tens )
{
case 2:
    printf("twenty");
case 3:
    printf("thirty");
// ...
}



最后,使用第二个switch语句打印数字的名称:



Finally, use a second switch statement to print the name of the ones digit:

switch( ones )
{
case 1:
    printf("one")
case 2:
    printf("two");
// ...
}



就这样!

-PaulH

在我看来,他是在寻求指导,而不是作弊.



That''s it!

-PaulH

It looks to me like he''s asking for guidance, not cheating.


这篇关于打印号码名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆