Code Forces 535 A. Tavas and Nafas(水~)

Description
给出一个0~99之间的数n,输出其英文表示
Input
一个整数n
Output
n的英文表示
Sample Input
99
Sample Output
ninety-nine
Solution
打表题
Code

#include<stdio.h>

char c1[21][11]={"zero","one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen","twenty"};
char c2[10][10]={"twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"};
int main()
{
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        if(n<=20)
            printf("%s\n",c1[n]);
        else if(n%10==0)
            printf("%s\n",c2[n/10-2]);
            else
                printf("%s-%s\n",c2[n/10-2],c1[n%10]);
    } 
    return 0;
} 

你可能感兴趣的:(Code Forces 535 A. Tavas and Nafas(水~))