# ACdream 1188 switch教学

Time Limit: 2000/1000MS (Java/Others) Memory Limit: 128000/64000KB (Java/Others)

#### Problem Description

Do you know how to read the phone numbers in English? Now let me tell you.

For example, In China, the phone numbers are 11 digits, like: 15012233444. Someone divides the numbers into 3-4-4 format, i.e. 150 1223 3444. While someone divides the numbers into 3-3-5 format, i.e. 150 122 33444. Different formats lead to different ways to read these numbers:

150 1223 3444 reads one five zero one double two three three triple four.

150 122 33444 reads one five zero one double two double three triple four.

Here comes the problem:

Given a list of phone numbers and the dividing formats, output the right ways to read these numbers.

Rules:

Single numbers just read them separately.

2 successive numbers use double.

3 successive numbers use triple.

5 successive numbers use quintuple.

6 successive numbers use sextuple.

7 successive numbers use septuple.

8 successive numbers use octuple.

9 successive numbers use nonuple.

10 successive numbers use decuple.

More than 10 successive numbers read them all separately.

#### Input

The first line of the input gives the number of test cases, T(1 ≤ T ≤ 100).

T test cases follow. Each line contains a phone number N(1 ≤ length of N ≤ 100) and the dividing format F, one or more positive integers separated by dashes (-), without leading zeros and whose sum always equals the number of digits in the phone number.

#### Output

For each test case, output one line containing "Case #x: y", where x is the case number (starting from 1) and y is the reading sentence in English whose words are separated by a space.

#### Sample Input

3
15012233444 3-4-4
15012233444 3-3-5
12223 2-3

#### Sample Output

Case #1: one five zero one double two three three triple four
Case #2: one five zero one double two double three triple four
Case #3: one two double two three

codejam

#### Manager

switch妮可真**6

#include <iostream>
#include <sstream>
#include <string>
#include <cmath>
using namespace std;

void doubi(int num,char x){
string str;
switch(x){
case '0':str=" zero";break;
case '1':str=" one";break;
case '2':str=" two";break;
case '3':str=" three";break;
case '4':str=" four";break;
case '5':str=" five";break;
case '6':str=" six";break;
case '7':str=" seven";break;
case '8':str=" eight";break;
case '9':str=" nine";break;
}
for(int i=0;i<num;i++)
cout<<str;
return ;
}
void pr(int num,char x)
{
switch(num){
case 1:break;
case 2:cout<<" double";break;
case 3:cout<<" triple";break;
case 5:cout<<" quintuple";break;
case 6:cout<<" sextuple";break;
case 7:cout<<" septuple";break;
case 8:cout<<" octuple";break;
case 9:cout<<" nonuple";break;
case 10:cout<<" decuple";break;
default :{
doubi(num,x);
return ;
}
}
switch(x){
case '0':cout<<" zero";break;
case '1':cout<<" one";break;
case '2':cout<<" two";break;
case '3':cout<<" three";break;
case '4':cout<<" four";break;
case '5':cout<<" five";break;
case '6':cout<<" six";break;
case '7':cout<<" seven";break;
case '8':cout<<" eight";break;
case '9':cout<<" nine";break;
}
}
int main()
{
int t;
cin>>t;
for(int p=1;p<=t;p++){
string str;
string rule;
cin>>str;
cin>>rule;
cout<<"Case #"<<p<<':';
stringstream ss;
ss<<rule;
int div=0;
int i=0;
int j=0;
while(ss>>div){
i++;
div=abs(div);//他把—当成负号了；
j+=div;
int num=1;;
for(;i<j;i++){
if(str[i-1]!=str[i]){
pr(num,str[i-1]);
num=1;
}
else
num++;
}
pr(num,str[i-1]);
}
cout<<endl;
}
}


• 本文已收录于以下专栏：

举报原因： 您举报文章：ACdream 1188 switch教学 色情 政治 抄袭 广告 招聘 骂人 其他 (最多只允许输入30个字)