# 1603

## 题目描述

（1）找出句子中所有用英文表示的数字(≤20)，列举在下：

（2）将这些数字平方后%100，如00,05,11,19,86,99。

（3）把这些两位数按数位排成一行，组成一个新数，如果开头为0，就去0。

（4）找出所有排列方法中最小的一个数，即为密码。

## 输入输出格式

1.分析：

1）题意分析：
题目里面我们就把字符串转转换成数字进行操作

2）1>该如何判断指定的字符串以及如何将字符串和相应的数字对应起来

``````char dic[30][30]={"zero","one","two","three","four","five","six","seven","eight","nine","ten",
"eleven","twelve", "thirteen", "fourteen",
"fifteen", "sixteen", "seventeen",
"eighteen", "nineteen", "twenty","a","both","another","first","second","third"};
int di[30] ={0,1,4,9,16,25,36,49,64,81,00,21,44,69,96,25,56,89,24,61,0,1,4,1,1,4,9};``````

``````if(!strcmp(s[i],dic[j])){
a[++top] = di[j];
}
//对于我们需要的判断是否字符串符合这些个相应
//利用strcmp来进行相等判断 strcmp(char1,char2);``````

2>如何消除最后输出的时候前面可能出现的“0”

``````//利用flag来判断这个输出是不是字段首个
for(j = 1;j <= top;j++) {
if(flag)
printf("%.2lld",a[j]);
else{
if(a[j]){
printf("%lld",a[j]);
flag=1;
}
}
}``````

3>如何求最小的数字组合

``````sort(a+1,a+top+1);
//进行快排 从小到大进行排序``````

``````#include <iostream>
#include <algorithm>
#include <cstdio>
#include<cstring>
using namespace std;
char dic[30][30]={"zero","one","two","three","four","five","six","seven","eight","nine","ten",
"eleven","twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen",
"eighteen", "nineteen", "twenty","a","both","another","first","second","third"};
int di[30] ={0,1,4,9,16,25,36,49,64,81,00,21,44,69,96,25,56,89,24,61,0,1,4,1,1,4,9};
unsigned long long int a[10],top,flag;
long long int i,j;
char s[100][100];
int main()
{
for(i = 1;i <= 6;i++){
cin >> s[i];
for(j = 0;j <= 26;j++){
if(!strcmp(s[i],dic[j])){
a[++top] = di[j];
}
}
}
sort(a+1,a+top+1);
for(j = 1;j <= top;j++) {
if(flag)
printf("%.2lld",a[j]);
else{
if(a[j]){
printf("%lld",a[j]);
flag=1;
}
}
}
if(!flag)	printf("0");
return 0;
}

``````

本文转自网络文章，转载此文章仅为分享知识，如有侵权，请联系博主进行删除。