日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

A-ID and password

發(fā)布時(shí)間:2024/4/18 编程问答 49 豆豆
生活随笔 收集整理的這篇文章主要介紹了 A-ID and password 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

這里

題目描述

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)制

#include<bits/stdc++.h> #define N 100005 #define ll long long using namespace std; int main() {string s;while (cin >> s) {int len = s.length();for (int i = 0; i < len; i++) {if (s[i] >= 'A' && s[i] <= 'z') {s[i] = s[i] ^ 32;}}cout << s << endl;}return 0; } 與50位技術(shù)專家面對(duì)面20年技術(shù)見證,附贈(zèng)技術(shù)全景圖

總結(jié)

以上是生活随笔為你收集整理的A-ID and password的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。