编写一个程序,要求用户输入一个两位数,然后显示该数的英文单词(用switch语句)
展开全部
确定要用switch? 两位数有90个呢。
var result = prompt("请输入一个一位数","");
switch(result){
case "0":
alert("Zero");
break;
case "1":
alert("One");
break;
case "2":
alert("Two");
break;
case "3":
alert("Three"行敬雀);
break;
稿判case "4":
alert("Four");
break;
}
用js简单实现了一个,放在浏览器档早可以直接运行。
展开全部
#include <stdio.h>
int main()
{
int a,b,c;
printf("Scanf a int number: ");
scanf("%d", &a);
if(a>=10 && a<租游卖20){
switch (a%10){
case 0:printf("ten");break;
case 1:printf("弊逗eleven");break;
case 2:printf("twelve");break;
case 3:printf("thirteen");break;
case 4:printf("fourteen");break;
case 5:printf("fifteen");break;
case 6:printf("sixteen");break;
case 7:printf("seventeen");break;
case 8:printf("eighteen");break;
case 9:printf("nineteen");break;
}
}
else{
switch (a/10){
case 2:printf("twenty");break;
case 3:printf("thirty");break;
case 4:printf("fourty");break;
case 5:printf("磨腊fifty");break;
case 6:printf("sixty");break;
case 7:printf("seventy");break;
case 8:printf("eighty");break;
case 9:printf("nighty");break;
}
printf(" - ");//打印“ - ”符号
switch (a%10){
case 0:printf("zero");break;
case 1:printf("one");break;
case 2:printf("two");break;
case 3:printf("three");break;
case 4:printf("four");break;
case 5:printf("five");break;
case 6:printf("six");break;
case 7:printf("seven");break;
case 8:printf("eight");break;
case 9:printf("nigh");break;
}}
return 0;
}
int main()
{
int a,b,c;
printf("Scanf a int number: ");
scanf("%d", &a);
if(a>=10 && a<租游卖20){
switch (a%10){
case 0:printf("ten");break;
case 1:printf("弊逗eleven");break;
case 2:printf("twelve");break;
case 3:printf("thirteen");break;
case 4:printf("fourteen");break;
case 5:printf("fifteen");break;
case 6:printf("sixteen");break;
case 7:printf("seventeen");break;
case 8:printf("eighteen");break;
case 9:printf("nineteen");break;
}
}
else{
switch (a/10){
case 2:printf("twenty");break;
case 3:printf("thirty");break;
case 4:printf("fourty");break;
case 5:printf("磨腊fifty");break;
case 6:printf("sixty");break;
case 7:printf("seventy");break;
case 8:printf("eighty");break;
case 9:printf("nighty");break;
}
printf(" - ");//打印“ - ”符号
switch (a%10){
case 0:printf("zero");break;
case 1:printf("one");break;
case 2:printf("two");break;
case 3:printf("three");break;
case 4:printf("four");break;
case 5:printf("five");break;
case 6:printf("six");break;
case 7:printf("seven");break;
case 8:printf("eight");break;
case 9:printf("nigh");break;
}}
return 0;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询