早教吧作业答案频道 -->其他-->
求c++程序(有注解),输入一串字母,输出对应的数字,a→1,b→2……z→26要求:输入的字母串不超过五个字母,且字母输入的顺序有要求,eg:aak,acxz,bce(有顺序的),如果是das,bhckj这类的输出0Consi
题目详情
求c++程序(有注解),输入一串字母,输出对应的数字,a→1,b→2……z→26
要求:输入的字母串不超过五个字母,且字母输入的顺序有要求,eg:aak,acxz,bce(有顺序的),如果是das,bhckj这类的输出0
Consider the English alphabet {a,b,c,...,z}.Using this alphabet,a set of valid words are to be formed that are in a strict lexicographic order.In this set of valid words,the successive letters of a word are in a strictly ascending order; that is,later letters in a valid word are always after previous letters with respect to their positions in the alphabet list {a,b,c,...,z}.
For example,
abc aep gwz
are all valid three-letter words,whereas
aab are cat
are not.
For each valid word associate an integer which gives the position of the word in the alphabetized list of words.That is:
a -> 1
b -> 2
z -> 26
ab -> 27
ac -> 28
az -> 51
bc -> 52
vwxyz -> 83681
Your program is to read a series of input lines.Each input line will have a single word on it,that will be from one to five letters long.For each word read,if the word is invalid give the number 0.If the word read is valid,give the word's position index in the above alphabetical list.
要求:输入的字母串不超过五个字母,且字母输入的顺序有要求,eg:aak,acxz,bce(有顺序的),如果是das,bhckj这类的输出0
Consider the English alphabet {a,b,c,...,z}.Using this alphabet,a set of valid words are to be formed that are in a strict lexicographic order.In this set of valid words,the successive letters of a word are in a strictly ascending order; that is,later letters in a valid word are always after previous letters with respect to their positions in the alphabet list {a,b,c,...,z}.
For example,
abc aep gwz
are all valid three-letter words,whereas
aab are cat
are not.
For each valid word associate an integer which gives the position of the word in the alphabetized list of words.That is:
a -> 1
b -> 2
z -> 26
ab -> 27
ac -> 28
az -> 51
bc -> 52
vwxyz -> 83681
Your program is to read a series of input lines.Each input line will have a single word on it,that will be from one to five letters long.For each word read,if the word is invalid give the number 0.If the word read is valid,give the word's position index in the above alphabetical list.
▼优质解答
答案和解析
main()
{
char s[10];
int i;
scanf("%s",&s);
for(i=0;s[i]!='\0'||s[i]5||s[i]
{
char s[10];
int i;
scanf("%s",&s);
for(i=0;s[i]!='\0'||s[i]5||s[i]
看了 求c++程序(有注解),输入...的网友还看了以下:
用A~Z字母作为每句话的第一个字母编英语短文用A~Z字母作为每句话的第一个字母编英语短文(故事也行 2020-04-08 …
下列关于单字母加密方法和多字母加密方法,说法不正确的是A.单字母加密法是用一个字母代替另一个 2020-05-24 …
下列关于单字母加密方法和多字母加密方法,说法不正确的是()。A.单字母加密法是用一个字母代替另一 2020-05-24 …
英语字母中含有e的字母发音的是:英语字母中含有a的字母发音的是: 2020-07-15 …
1·量筒、水、木块、测油的密度.2·量筒、水、测石块密度.(要纯字母运算,请用下角标注明各物理量, 2020-07-20 …
单个字母a,发长元音/ei/的英语单词有哪些?越多越好看清要求:1、是单个字母a,在单词中长元音/ 2020-07-21 …
英语主语谓语用的字母例如有S+V+P句型,请把所有这类字母和他们的意思写出来 2020-07-22 …
从键盘输入一串字符,然后将每一个字母变成它后面的字母输出,如将A变成B,Z变成A,非字母字符不变, 2020-07-23 …
读图,回答下列各题(1)图中A-I字母所示地区中,人口稠密的有A、B、、,人口稀疏的有、、、H(填字 2021-01-18 …
设A=B={a,b,c,d,e,…,x,y,z}(元素为26个英文字母),作映射A→B为:并称A中字 2021-02-09 …