CodeForces 131A cAPS lOCK
2016-07-19 14:43
323 查看
For example, the case of the letters that form words "hELLO", "HTTP", "z" should be changed.
它这句题意很关键,是解决问题关键
#include<stdio.h>
#include<iostream>
#include<math.h>
#include<string.h>
#include<iomanip>
#include<stdlib.h>
#include<ctype.h>
#include<algorithm>
#include<deque>
#include<functional>
#include<iterator>
#include<vector>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#define CPY(A, B) memcpy(A, B, sizeof(A))
typedef long long LL;
typedef unsigned long long uLL;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const LL INFF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
const double OO = 1e20;
const double PI = acos (-1.0);
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
using namespace std;
const int maxn=1250;
char s[maxn];
char rev (char ch) {
return (islower (ch) ) ?toupper (ch) :tolower (ch);
}
int main() {
scanf ("%s",s);
int len=strlen (s),sum=0;
//‘z’
if (len==1) {printf ("%c",rev (s[0]) ); return 0;}
for (int i=0; i<len; i++) {
if (isupper (s[i]) ) { ++sum; }
}
//HTTP,cAPS
if (sum==len|| (sum==len-1&&islower (s[0]) ) ) {
for (int i=0; i<len; ++i) {
printf ("%c",rev (s[i]) );
}
return 0;
}
puts (s);
return 0;
}
For example, the case of the letters that form words "hELLO", "HTTP", "z" should be changed.
它这句题意很关键,是解决问题关键
#include<stdio.h>
#include<iostream>
#include<math.h>
#include<string.h>
#include<iomanip>
#include<stdlib.h>
#include<ctype.h>
#include<algorithm>
#include<deque>
#include<functional>
#include<iterator>
#include<vector>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#define CPY(A, B) memcpy(A, B, sizeof(A))
typedef long long LL;
typedef unsigned long long uLL;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const LL INFF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
const double OO = 1e20;
const double PI = acos (-1.0);
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
using namespace std;
const int maxn=1250;
char s[maxn];
char rev (char ch) {
return (islower (ch) ) ?toupper (ch) :tolower (ch);
}
int main() {
scanf ("%s",s);
int len=strlen (s),sum=0;
//‘z’
if (len==1) {printf ("%c",rev (s[0]) ); return 0;}
for (int i=0; i<len; i++) {
if (isupper (s[i]) ) { ++sum; }
}
//HTTP,cAPS
if (sum==len|| (sum==len-1&&islower (s[0]) ) ) {
for (int i=0; i<len; ++i) {
printf ("%c",rev (s[i]) );
}
return 0;
}
puts (s);
return 0;
}
相关文章推荐
- (皇后移动类)八数码难题引发的搜索思考及总结
- Web---演示servlet技术(servlet生命周期),解决中文乱码问题
- Android开发技术周报 Issue#32
- PDA移动POS终端系统,实现专柜或店铺的收货、零售、盘点通过无线网络直接连接总部中央数据库,实现高效安全的移动供应链管理
- Java动态代理(一)动态类Proxy的使用
- 关于TextView与SpannableStringBuilder的使用
- python3.x和python2.x区别
- Powershell AWS 自动化管理 (11) - 创建一个高可用的WordPress博客(中)
- 暑假训练赛20160719
- 1.虚函数的继承与派生;2.多文件静态对象的定义顺序,3模板注意,4mysql二、十六进制, 4颜色名称,5QSvgRenderer真实rect和viewboxrect转换
- ubuntu16.04 安装Hadoop2.7.2
- 分配空间的三种函数——malloc,calloc,realloc
- Android中定时器Timer和TimerTask的启动,停止,暂停,继续等操作实例
- Java逐行读写TXT文件
- python对redis的常用操作 上 (对列表、字符串、散列结构操作)
- Font Awesome字体图标
- GreenDao_2.介绍GreenDao
- 为自己建立一个好的企业构思
- mongo模糊查询
- linux下面ln -s软连接(No package 'libxml-2.0' found)