南昌大学航天杯第二届程序设计竞赛校赛网络同步赛 A

链接:https://www.nowcoder.com/acm/contest/122/A
来源:牛客网

题目描述

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.
示例1

输入

JDJhadjsazA
ksfjkkdSDJ23

输出

jdjHADJSAZa
KSFJKKDsdj23

 1 #include<iostream>
 2 #include<cstdio>
 3 #include<cmath>
 4 #include<cstring>
 5 using namespace std;
 6 #define maxn 2000
 7 
 8 int main()
 9 {
10     string s;
11     while(cin>>s){
12         for(int i=0;i<s.length();i++){
13             if(s[i]>='a'&&s[i]<='z'){
14                 printf("%c",s[i]-32);
15             }else if(s[i]>='A'&&s[i]<='Z'){
16                 printf("%c",s[i]+32);
17             }else{
18                 printf("%c",s[i]);
19             }
20         }
21         printf("\n");
22     }
23     return 0;
24 }


猜你喜欢

转载自www.cnblogs.com/yinghualuowu/p/9063308.html