A22530. 程序二:#include<iostream) #include<string> using namespace std; int main() { string num_list="11223344555666777888999000"; string message; cin>>message; for(int i=0;i<message. length();i++) if((message[…
填空题
较易
知识点
题目描述
程序二:
#include<iostream)
#include<string>
using namespace std;
int main()
{
string num_list="11223344555666777888999000";
string message;
cin>>message;
for(int i=0;i<message. length();i++)
if((message[i]>='0')&&(message[i]<='9'))
cout<<num_list[i];
else if((message[i]>='A')&&(message[i]<='Z'))
cout<<num_list[message[i]-'A'];
cout<<endl;
return 0;
}| 题号 | 第1题 | 第2题 | 第3题 | 第4题 |
|---|---|---|---|---|
| 输入数据 | AK | CODE | XM_2023 | LOVEC++1024 |
| 输出数据 | 34 | 35 | 36 | 37 |
参考答案
15、2723、062334、679324555答案解析
该题目对输入的字符串进行判断,如果输入的是数字字符,直接找出该字符下标在 num_list 中相同下标的元素;如果输入的是大写字母,找出字母对应 ASCII 码减去A 的 ASCII 码的结果,对应 num_list 中下标的元素:其他的输入直接跳过
上一题
下一题