A-ID and password
這里
題目描述
Users prefer simple passwords that are easy to remember, but such passwords are often insecure. Some sites use random computer-generated passwords, but users have a hard time remembering them. But today I improved the website system, which greatly reduced the probability of password being cracked. So we can generate a simple password for each ID by default.
Each id has its initial password.
Do the following two jobs at the same time:
1.Turn uppercase letters to lowercase letters
2.Turn lowercase letters to uppercase letters
You can get the initial password for the id.
輸入描述:
The input consists of one or more identities(ID), one per line.
The length of each id is between 1 and 100. Each id only consists of letters and digits.
輸出描述:
For each id, output the corresponding initial password.
輸入
JDJhadjsazA
ksfjkkdSDJ23
輸出
jdjHADJSAZa
KSFJKKDsdj23
思路
題目很簡(jiǎn)單,就是字符串大寫變小寫,小寫變大寫。
但是看到一個(gè)很有意思的代碼
mycode
#include<bits/stdc++.h> #define N 100005 using namespace std;int main() { // freopen("in.txt", "r", stdin);string s;while (cin >> s) {string t;int len = s.length();for (int i = 0;i < len; i++) {if (isdigit(s[i])) t += s[i];else {if (s[i] >= 'A' && s[i] <= 'Z') t += s[i] + 32;if (s[i] >= 'a' && s[i] <= 'z') t += s[i] - 32;}}cout << t << endl;}return 0; }othercode
int (‘a(chǎn)’) = 97 1100001
int (‘A’) = 65 1000001
‘a(chǎn)’ - ‘z’對(duì)32異或,剛好等于 ‘A’ - ‘Z’
‘A’ - ‘Z’對(duì)32異或,結(jié)果等于‘a(chǎn)’ - ‘z’
可以手動(dòng)模擬二進(jìn)制
總結(jié)
以上是生活随笔為你收集整理的A-ID and password的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: K-序列求和 (逆元)
- 下一篇: B取石子