当前位置:网站首页>Openjudge noi 1.7 10: simple password
Openjudge noi 1.7 10: simple password
2022-07-07 01:02:00 【Jun Yi_ noip】
【 Topic link 】
OpenJudge NOI 1.7 10: Simple code
【 Topic test site 】
1. ASCII code
2. character string
【 Their thinking 】
We can know by analyzing the law , The plaintext letter is the first number of ciphertext characters 5 Letters .
solution 1: Letters correspond to numbers
Put the letters c Turn to the corresponding number ,A Corresponding number 0,B Corresponding number 1… Z Corresponding number 25, Method is c - 'A'
- If
c - 'A' >= 5
, Then the number corresponding to the plaintext letter isc - 'A' - 5
- If
c - 'A' < 5
, Then the number corresponding to the plaintext letter isc - 'A' + 26 - 5
Last , Then turn numbers into characters
Finally integrated intoc = (c - 'A' + 26 - 5) % 26 + 'A'
solution 2: Directly judge the current letter ASCII code
If the current ciphertext alphabet variable c yes ’E’ And ’E’ The previous letter , Then the corresponding plaintext letter is c+21
If the current ciphertext alphabet variable c yes ’F’ And ’F‘ The letter after , Then the corresponding plaintext letter is c-5
【 Solution code 】
solution 1: A character array Letters correspond to numbers
#include<bits/stdc++.h>
using namespace std;
int main()
{
char s[205];
cin.getline(s, 205);
int len = strlen(s);
for(int i = 0; i < len; ++i)
{
if(s[i] >= 'A' && s[i] <= 'Z')
s[i] = (s[i] - 'A' + 26 - 5) % 26 + 'A';
}
cout << s;
return 0;
}
solution 2:string class Judge the character ASCII code
#include<bits/stdc++.h>
using namespace std;
int main()
{
string s;
getline(cin, s);
for(int i = 0; i < s.length(); ++i)
{
if(s[i] >= 'A' && s[i] <= 'E')
s[i] = s[i] + 21;
else if(s[i] >= 'F' && s[i] <= 'Z')
s[i] = s[i] - 5;
}
cout << s;
return 0;
}
solution 3: Keep reading in characters , Judge output
#include<bits/stdc++.h>
using namespace std;
int main()
{
char c;
c = getchar();
while(c != '\n')
{
if (c >= 'A' && c <= 'Z')
putchar((c - 'A' - 5 + 26) % 26 + 'A');
else
putchar(c);
c = getchar();
}
return 0;
}
边栏推荐
- threejs图片变形放大全屏动画js特效
- alexnet实验偶遇:loss nan, train acc 0.100, test acc 0.100情况
- Dell Notebook Periodic Flash Screen Fault
- What kind of experience is it to realize real-time collaboration in jupyter
- paddlehub应用出现paddle包报错的问题
- String comparison in batch file - string comparison in batch file
- 建立自己的网站(17)
- A brief history of deep learning (II)
- Advanced learning of MySQL -- basics -- multi table query -- self join
- Explain in detail the implementation of call, apply and bind in JS (source code implementation)
猜你喜欢
[Batch dos - cmd Command - Summary and Summary] - String search, find, Filter Commands (FIND, findstr), differentiation and Analysis of Find and findstr
C9 colleges and universities, doctoral students make a statement of nature!
界面控件DevExpress WinForms皮肤编辑器的这个补丁,你了解了吗?
Deeply explore the compilation and pile insertion technology (IV. ASM exploration)
Dell Notebook Periodic Flash Screen Fault
城联优品入股浩柏国际进军国际资本市场,已完成第一步
第七篇,STM32串口通信编程
【YoloV5 6.0|6.1 部署 TensorRT到torchserve】环境搭建|模型转换|engine模型部署(详细的packet文件编写方法)
【软件逆向-自动化】逆向工具大全
Part 7: STM32 serial communication programming
随机推荐
Dell笔记本周期性闪屏故障
Installation and testing of pyflink
通过串口实现printf函数,中断实现串口数据接收
[software reverse automation] complete collection of reverse tools
Summary of being a microservice R & D Engineer in the past year
【JVM调优实战100例】05——方法区调优实战(下)
Threejs image deformation enlarge full screen animation JS special effect
线段树(SegmentTree)
[Niuke classic question 01] bit operation
Activereportsjs 3.1 Chinese version | | | activereportsjs 3.1 English version
stm32F407-------DAC数模转换
. Bytecode structure of class file
OSPF configuration command of Huawei equipment
再聊聊我常用的15个数据源网站
详解OpenCV的矩阵规范化函数normalize()【范围化矩阵的范数或值范围(归一化处理)】,并附NORM_MINMAX情况下的示例代码
Building a dream in the digital era, the Xi'an station of the city chain science and Technology Strategy Summit ended smoothly
STM32开发资料链接分享
Advanced learning of MySQL -- basics -- transactions
.class文件的字节码结构
Dr selection of OSPF configuration for Huawei devices