用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.

来源:学生作业帮助网 编辑:作业帮 时间:2024/04/30 03:46:52
用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.

用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.
用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.

用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.
#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");
}