3391:【例68.2】 简单密码
[例 68.2] 简单密码
C++代码:
/*
NOI / 1.7编程基础之字符串
10简单密码 2021.12.5 AC
http://noi.openjudge.cn/ch0107/solution/31858112/
*/
#include<bits/stdc++.h>
using namespace std;
int main()
{
string c;
getline(cin,c);
char t2[26]={'V', 'W', 'X', 'Y', 'Z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U'};
for(int i=0;i<c.length();++i)
{
if('A'<=c[i]&&c[i]<='Z')
{
c[i]=t2[c[i]-'A'];
}
}
cout<<c;
return 0;
}
#include <bits/stdc++.h>
using namespace std;
int main()
{
string s;
char a[30]={"V""W""X""Y""Z""A""B""C""D""E""F""G""H""I""J""K""L""M""N""O""P""Q""R""S""T""U"};
getline(cin,s);
int len=s.length();
for(int i=0;i<len;i++){
if(s[i]>='A'&&s[i]<='Z'){
s[i]=a[s[i]-'A'];
}
}
cout<<s;
return 0;
}
python3程序:
"""
1.7编程基础之字符串 10 简单密码
http://noi.openjudge.cn/ch0107/10/
"""
character = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
string = input()
password_character = ""
for i in range(len(string)):
c = string[i]
if c in character:
password_character = password_character + character[(character.index(c) - 5)%26]
else:
password_character = password_character + c
print(password_character)
python习题集整理汇总
第十一届蓝桥杯青少组Python竞赛真题
python算法书籍简介-2022.06.13
python算法和数据结构书籍(二)
啊哈算法(python)