<NOIP> 21 . P1914 小书童——密码
2017-06-30 16:05
381 查看
题解:这是洛谷的第21道题目,本题的重点是当字符为‘Z’时,它的下一位是‘A’。
源代码:
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <sstream>
#include <stdlib.h>
using namespace std;
int main()
{
int movenumber;
string password;
char *Realpassword = new char[password.size()];
cin >> movenumber;
cin >> password;
for (size_t i = 0; i < password.size(); i++)
{
int loop = 0;
char c = password[i];
if (c >= 'A'&&c <= 'Z')
{
while (loop < movenumber)
{
if (c == 'Z')
c = 'A';
else
c++;
loop++;
}
}
else if(c >= 'a'&&c <= 'z')
{
while (loop < movenumber)
{
if (c == 'z')
c = 'a';
else
c++;
loop++;
}
}
cout << c;
}
cout << endl;
system("pause");
return 0;
}
源代码:
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <sstream>
#include <stdlib.h>
using namespace std;
int main()
{
int movenumber;
string password;
char *Realpassword = new char[password.size()];
cin >> movenumber;
cin >> password;
for (size_t i = 0; i < password.size(); i++)
{
int loop = 0;
char c = password[i];
if (c >= 'A'&&c <= 'Z')
{
while (loop < movenumber)
{
if (c == 'Z')
c = 'A';
else
c++;
loop++;
}
}
else if(c >= 'a'&&c <= 'z')
{
while (loop < movenumber)
{
if (c == 'z')
c = 'a';
else
c++;
loop++;
}
}
cout << c;
}
cout << endl;
system("pause");
return 0;
}
相关文章推荐
- <NOIP> 14 . P1047 校门外的树
- <Power Shell>21 如何从远程客户端快速提取信息 推荐
- <Git>Windows7的Git Bash设置密码缓存 (cache credential)
- <NOIP> 4 . P1425 小鱼的游泳时间
- <NOIP> 7 . P1008 三连击
- <NOIP> 27 . P1618 三连击(升级版)
- P1914 小书童——密码
- <NOIP> 15 . P1427 小鱼的数字游戏
- <二分||线段树>【noip 2012】codevs 1217 借教室
- <转载>获取运行中的TeamViewer的账号和密码
- 小书童——密码(p1914)
- 洛谷 P1914 小书童——密码【字符串+模拟】
- <密码的实现>输入密码的时候,显示“*”,而不是显示输入内容
- <加强安全> 一键防止SSH密码被暴力破解
- <NOIP> 16 . P1055 ISBN号码
- luogu 1914 小书童——密码
- <linux报错解决>在Fedora21下安装vmware报错的解决办法
- <原博客>某人在玩游戏的时候输入密码123456后成功进入游戏(输错5次则被强行退出)
- <NOIP> 18 . P1308 统计单词数
- <noip>陶陶摘苹果