C - cAPS lOCK
Problem description
wHAT DO WE NEED cAPS LOCK FOR?
Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passage.
Let's consider that a word has been typed with the Caps lock key accidentally switched on, if:
- either it only contains uppercase letters;
- or all letters except for the first one are uppercase.
In this case we should automatically change the case of all letters. For example, the case of the letters that form words "hELLO", "HTTP", "z" should be changed.
Write a program that applies the rule mentioned above. If the rule cannot be applied, the program should leave the word unchanged.
Input
The first line of the input data contains a word consisting of uppercase and lowercase Latin letters. The word's length is from 1 to 100 characters, inclusive.
Output
Print the result of the given word's processing.
Examples
Input
cAPS
Output
Caps
Input
Lock
Output
Lock
解题思路:题目的意思就是给定的字符串如果有这两种情况:①:所有字符都为大写字母;②:除了第一个是小写字母以外,其余都是大写字母,如果满足其中任意一种情况,就修改整个字符串(大写变小写,小写变大写),否则直接输出原字符串,简单水过!
AC代码:
#include<bits/stdc++.h>
using namespace std;
int main(){
char s[];bool flag;
cin>>s;
if(s[]>='A' && s[]<='Z'){
flag=true;
for(int i=;s[i]!='\0';++i)
if(s[i]>='a' && s[i]<='z'){flag=false;break;}
if(flag)for(int i=;s[i]!='\0';++i)s[i]+=;
}else{
flag=true;
for(int i=;s[i]!='\0';++i)
if(s[i]>='a' && s[i]<='z'){flag=false;break;}
if(flag){
s[]-=;
for(int i=;s[i]!='\0';++i)s[i]+=;
}
}
cout<<s<<endl;
return ;
}
C - cAPS lOCK的更多相关文章
- ubunut 14.04 将Caps Lock设置为Control
入手了emacs,一直折腾想把caps Lock设置为control键. 网上看到一个用gnome里找到系统-首选项之类可以直接设置的.在14.04版的ub中是找不到的(新版设置太坑,只有那么几个选项 ...
- CodeForces 131A cAPS lOCK
cAPS lOCK Time Limit:500MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u Submit St ...
- ubuntu 交换ctrl与caps lock 键
The relevant option is no longer available in the settings menu in Ubuntu 13.10; this has been repor ...
- 交换Ctrl和Caps Lock键
由于使用vim的缘故,就把Ctrl和Caps Lock键交换了,在ubuntu系统下使用系统设置可以很简单地进行全局替换. 在ubuntu下习惯了之后在window下就经常按错...后来决定也把win ...
- 转:判断Caps Lock键是否打开,如果打开则关闭
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...
- Mac下常用按键符号⌘(command)、⌥(option)、⇧(shift)、⇪(caps lock)、⌃(control)、↩(return)、⌅(enter)
常用符号如下: ⌘(command) ⌥(option) ⇧(shift) ⇪(caps lock) ⌃(control) ↩(return) ⌅(enter) 对应键盘的位置如下: 如果每次都不记得 ...
- Mac OS 10.12后Caps lock(大写键)无法使用的解决办法
▲打开设置中的键盘选项,并切换至输入源选项标签, ▲取消勾选“使用大写锁定键来回切换“美国英文””, ▲这时再按下Caps lock即可正常使用大小写切换. ▲Update:目前macOS 10.12 ...
- OSX - Mac OS 10.12后Caps lock(大写键)无法使用的解决办法
我在OSX的虚拟机中安装了windows 7 操作系统,但是发现在win7下,大写键不起作用,通过下面方面搞定了! ▲打开设置中的键盘选项,并切换至输入源选项标签, ▲取消勾选“使用大写锁定键来回切换 ...
- 交换左Ctrl键和Caps lock键
Windows 10 Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control ...
随机推荐
- vmware vSphere client中,选择文件->部署OVF模板,报错处理方法
在vmware vSphere client中,选择文件->部署OVF模板,选择指定的OVA文件,按步骤进行,则会出现这样的错误:此OVF软件包使用了不受支持的功能.OVF软件包需要不支持的硬件 ...
- 《程序设计基础》实验题目2 c文件读取(反序列化?) 链表排序
题目: 每个学生的信息卡片包括学号.姓名和成绩三项.定义存储学生信息的单向链表的结点类型:编写函 数,由文件依次读入 n(n≥0)个学生的信息,创建一个用于管理学生信息的单向链表:编写函数,对 该链表 ...
- 51nod1049 最大子段和【动态规划】
N个整数组成的序列a[1],a[2],a[3],-,a[n],求该序列如a[i]+a[i+1]+-+a[j]的连续子段和的最大值.当所给的整数均为负数时和为0. 例如:-2,11,-4,13,-5,- ...
- generating multiple ordered files in python
Goal: To generate =35= files named 'capitalsquiz1.txt', 'capitalsquiz2.txt'...'capitalsquiz35.txt' * ...
- PAT 1114 Family Property
This time, you are supposed to help us collect the data for family-owned property. Given each person ...
- 利用fontforge制作自己的字体
最近手伤了,写代码特别慢,索性就干干一些奇奇怪怪的事情. 发现我电脑上的中文字体很是奇怪,于是便去找了中英混合的等宽字体. 满足条件的只找到了YaHei Consolas Hybrid,是微软的Con ...
- [tsA1491][2013中国国家集训队第二次作业]家族[并查集]
m方枚举,并查集O(1)维护,傻逼题,,被自己吓死搞成神题了... #include <bits/stdc++.h> using namespace std; struct tri { i ...
- Spring Boot开发HTTPS协议的REST接口
Spring Boot开发HTTP的REST接口流程在前文中已经描述过,见<SpringBoot开发REST接口>. 如需要支持HTTPS,只需要在如上基础上进行设置.修改/resourc ...
- 虚拟机+centOS挂载ISO步骤
https://blog.csdn.net/u010612373/article/details/52240447
- 洛谷 P1186 玛丽卡
P1186 玛丽卡 题目描述 麦克找了个新女朋友,玛丽卡对他非常恼火并伺机报复. 因为她和他们不住在同一个城市,因此她开始准备她的长途旅行. 在这个国家中每两个城市之间最多只有一条路相通,并且我们知道 ...