您的位置:首页 > 其它

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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: