用C语言写下面一个程序,最好用Switch语句
来源:学生作业帮 编辑:大师作文网作业帮 分类:综合作业 时间:2024/10/04 07:25:23
用C语言写下面一个程序,最好用Switch语句
write a program that tasks an intger keyd in from the terminal and extracts and extracts and displays each digit of the integer int English.So,if the user types int 932,the program should display.
write a program that tasks an intger keyd in from the terminal and extracts and extracts and displays each digit of the integer int English.So,if the user types int 932,the program should display.
#include <stdio.h>
//显示每个数字的英文
void displayEnglish(int num)
{
switch(num)
{
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("nine ");break;
default:
printf("error.\n");
}
}
void main()
{
printf("输入一个整数:");
int num;
scanf("%d",&num);
do
{
displayEnglish(num%10);
num/=10;
} while(num>0);
printf("\n");
}
//显示每个数字的英文
void displayEnglish(int num)
{
switch(num)
{
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("nine ");break;
default:
printf("error.\n");
}
}
void main()
{
printf("输入一个整数:");
int num;
scanf("%d",&num);
do
{
displayEnglish(num%10);
num/=10;
} while(num>0);
printf("\n");
}
用C语言写下面一个程序,最好用Switch语句
一C语言if语句程序,求用switch改写!
C语言,分别用if 语句和switch语句编写程序求分段函数的值
求C语言!用switch编写一个计算分段函数的程序!
用C语言怎么写下面这个程序?要运算步骤不是直接写输出的.
简单的C语言题 编写一程序,要求输入x的值,输出y的值.要求分别用switch语句和嵌套的if语句写.
在C语言中,if语句和switch语句在构成分支程序上各有什么特点?
谁能帮我写下面计算的c语言程序,
C语言中switch语句改错
用SWITCH函数写,C语言
C语言编一个1+2+3+到n得程序用for语句
若a小于100则将下列程序写成switch语句 C语言菜鸟啊 大神们有时间帮个忙啊 switch写我不会啊