Codeforces Round #299 (Div. 2)A. Tavas and Nafas

Codeforces Round #299 (Div. 2)A. Tavas and Nafas点击进入题目页面
A. Tavas and Nafas
time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard output
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.

Sample test(s)
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 .

题意:输入1到99,让你输出英文。
题解:请看代码。
代码如下:

#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
void print_1(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;
  case 10:printf("ten");break;
  case 11:printf("eleven");break;
  case 12:printf("twelve");break;
  case 13:printf("thirteen");break;
  case 14:printf("fourteen");break;
  case 15:printf("fifteen");break;
  case 16:printf("sixteen");break;
  case 17:printf("seventeen");break;
  case 18:printf("eighteen");break;
  case 19:printf("nineteen");break;
  case 20:printf("twenty");break;
  case 30:printf("thirty");break;
  case 40:printf("forty");break;
  case 50:printf("fifty");break;
  case 60:printf("sixty");break;
  case 70:printf("seventy");break;
  case 80:printf("eighty");break;
  case 90:printf("ninety");break;
  }
}
int main()
{
  int s;
  scanf("%d",&s);
  if(s<=20) {print_1(s);printf("\n");}
  else if(s%10==0) {print_1(s);printf("\n");}
  else {
    print_1(s/10*10);printf("-");print_1(s%10);printf("\n");
  }
  return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值