标签:
题目链接:http://www.codeforces.com/problemset/problem/131/A
题意:字符串大小写转换。
C++代码:
#include <cstdio> #include <cstring> char s[110]; bool islow(char c) { return c >= ‘a‘ && c <= ‘z‘; } char up(char c) { return c - 32; } char low(char c) { return c + 32; } bool check() { char *t = s; t ++; while (*t) { if (islow(*t)) return true; t ++; } return false; } int main() { scanf("%s", s); if (check()) { puts(s); } else { char *t = s; while (*t) { if (islow(*t)) putchar(up(*t)); else putchar(low(*t)); t ++; } } return 0; }
codeforces水题100道 第二十六题 Codeforces Beta Round #95 (Div. 2) A. cAPS lOCK (strings)
标签:
原文地址:http://www.cnblogs.com/moonlightpoet/p/5690060.html