Tavas and Nafas

Description
Today Tavas got his test result as an integer score and he wants to share it with his girlfriend, Nafas.

His phone operating system is Tavdroid, and its keyboard doesn’t have any digits! He wants to share his score with Nafas via text, so he has no choice but to send this number using words.

He ate coffee mix without water again, so right now he’s really messed up and can’t think.

Your task is to help him by telling him what to type.

Input
The first and only line of input contains an integer s (0 ≤ s ≤ 99), Tavas’s score.

Output
In the first and only line of output, print a single string consisting only from English lowercase letters and hyphens (’-’). Do not use spaces.

Examples
Input
6
Output
six
Input
99
Output
ninety-nine
Input
20
Output
twenty
Note
You can find all you need to know about English numerals in http://en.wikipedia.org/wiki/English_numerals .

C语言版本一

#include <stdio.h>
#include <stdlib.h>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

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

C语言版本二

    #include <stdio.h>
 
int main()
{
    char *arr1[]={"zero","one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen","twenty"};
    char *arr2[]={"twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"};
    int s;
    scanf("%d",&s);
    if(s<=20)
    {
		printf("%s",arr1[s]);
	}
	else
    {
        printf("%s",arr2[s/10-2]);
        if(s%10)
        {
            printf("-%s",arr1[s%10]);
        }
    }
    return 0;
}

C++版本一

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
int main()
{
    // freopen("shuju.txt", "r", stdin);
    int n;
    cin >> n;
    if(n == 0)
        printf("zero\n");
    else if(n == 1)
        printf("one\n");
    else if(n == 2)
        printf("two\n");
    else if(n == 3)
        printf("three\n");
    else if(n == 4)
        printf("four\n");
    else if(n == 5)
        printf("five\n");
    else if(n == 6)
        printf("six\n");
    else if(n == 7)
        printf("seven\n");
    else if(n == 8)
        printf("eight\n");
    else if(n == 9)
        printf("nine\n");
    else if(n == 10)
        printf("ten\n");
    else if(n == 11)
        printf("eleven\n");
    else if(n == 12)
        printf("twelve\n");
    else if(n == 13)
        printf("thirteen\n");
    else if(n == 14)
        printf("fourteen\n");
    else if(n == 15)
        printf("fifteen\n");
    else if(n == 16)
        printf("sixteen\n");
    else if(n == 17)
        printf("seventeen\n");
    else if(n == 18)
        printf("eighteen\n");
    else if(n == 19)
        printf("nineteen\n");
    else if(n == 20)
        printf("twenty\n");
    else if(n == 30)
        printf("thirty\n");
    else if(n == 40)
        printf("forty\n");
    else if(n == 50)
        printf("fifty\n");
    else if(n == 60)
        printf("sixty\n");
    else if(n == 70)
        printf("seventy\n");
    else if(n == 80)
        printf("eighty\n");
    else if(n == 90)
        printf("ninety\n");
    else
    {
        int a = n / 10, b = n % 10;
        if(a == 2)
            printf("twenty-");
        else if(a == 3)
            printf("thirty-");
        else if(a == 4)
            printf("forty-");
        else if(a == 5)
            printf("fifty-");
        else if(a == 6)
            printf("sixty-");
        else if(a == 7)
            printf("seventy-");
        else if(a == 8)
            printf("eighty-");
        else if(a == 9)
            printf("ninety-");
        if(b == 1)
            printf("one\n");
        else if(b == 2)
            printf("two\n");
        else if(b == 3)
            printf("three\n");
        else if(b == 4)
            printf("four\n");
        else if(b == 5)
            printf("five\n");
        else if(b == 6)
            printf("six\n");
        else if(b == 7)
            printf("seven\n");
        else if(b == 8)
            printf("eight\n");
        else if(b == 9)
            printf("nine\n");
    }
    return 0;
}
全部评论

相关推荐

10-25 22:20
门头沟学院 Java
代码飞升:同学院本,个人亮点去了,打招呼里面的废话也去了,学院本就是路边一条,明天拉满然后该学还是学,小厂也行尽量先有一段实习。另外你的项目描述写的不好,具体列一下可被提问的点,然后量化一下指标或者收益吧
投了多少份简历才上岸
点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务