首页 > 其他 > 详细

codeforces水题100道 第二十六题 Codeforces Beta Round #95 (Div. 2) A. cAPS lOCK (strings)

时间:2016-07-21 00:24:37      阅读:252      评论:0      收藏:0      [点我收藏+]

题目链接: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;
}
C++

 

codeforces水题100道 第二十六题 Codeforces Beta Round #95 (Div. 2) A. cAPS lOCK (strings)

原文:http://www.cnblogs.com/moonlightpoet/p/5690060.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!