Created
October 4, 2012 16:15
-
-
Save Abreto/3834680 to your computer and use it in GitHub Desktop.
用语言描述的三位数
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Program E6.1 - print nature language for a number. */ | |
#include <stdio.h> | |
#include <stdlib.h> | |
int main(void) | |
{ | |
char map[][4] = {"零","一","二","三","四","五","六","七","八","九"}; | |
int num = 0; | |
printf("Please enter a three-digit number: "); | |
scanf("%d", &num); | |
if( (num/10) % 10 == 0 ) | |
printf("%s百零%s\n", map[ (num/100) % 10 ], map[ num % 10 ]); | |
else | |
printf("%s百%s十%s\n", map[ (num/100) % 10 ], map[ (num/10) % 10 ], map[ num % 10 ]); | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
忘了个位为零的情况