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

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

时间: 2024-10-11 02:06:37

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

codeforces水题100道 第二十五题 Codeforces Round #197 A. Helpful Maths (Div. 2) (strings)

题目链接:http://www.codeforces.com/problemset/problem/339/A题意:重新组合加法字符串,使得按照1,2,3的顺序进行排列.C++代码: #include <iostream> #include <string> using namespace std; int cnt[3]; string s, ans = ""; int main() { cin >> s; int len = s.length();

codeforces水题100道 第二十四题 Codeforces Beta Round #85 (Div. 2 Only) A. Petya and Strings (strings)

题目链接:http://www.codeforces.com/problemset/problem/112/A题意:忽略大小写,比较两个字符串字典序大小.C++代码: #include <cstdio> #include <cstring> int cmp(char *s, char *t) { while (*s) { if (*s <= 'Z') *s += 32; if (*t <= 'Z') *t += 32; if (*s < *t) return -1

codeforces水题100道 第十六题 Codeforces Round #164 (Div. 2) A. Games (brute force)

题目链接:http://www.codeforces.com/problemset/problem/268/A题意:足球比赛中如果主场球队的主场球衣和客队的客队球衣颜色一样,那么要求主队穿上他们的可对球衣,现在有n个球队,每一球队的主场球衣和客场球衣的颜色都告诉你了,它们两两之间要比一场赛.求其中主队穿客场球衣的比赛场数.C++代码: #include <iostream> using namespace std; const int maxn = 33; int x[maxn], y[max

codeforces水题100道 第二十二题 Codeforces Beta Round #89 (Div. 2) A. String Task (strings)

题目链接:http://www.codeforces.com/problemset/problem/118/A题意:字符串转换……C++代码: #include <string> #include <iostream> using namespace std; string s; bool _in(char c, string s) { for (int i =0 ; i < s.length(); i ++) if (c == s[i]) return true; retu

codeforces水题100道 第二十题 Codeforces Round #191 (Div. 2) A. Flipping Game (brute force)

题目链接:http://www.codeforces.com/problemset/problem/327/A题意:你现在有n张牌,这些派一面是0,另一面是1.编号从1到n,你需要翻转[i,j]区间的牌一次,使得看到的牌是1的数量最大.C++代码: #include <iostream> using namespace std; const int maxn = 110; int n, a[maxn], sum[maxn]; int flip(int L, int R) { int a1 =

codeforces水题100道 第十八题 Codeforces Round #289 (Div. 2, ACM ICPC Rules) A. Maximum in Table (brute force)

题目链接:http://www.codeforces.com/problemset/problem/509/A题意:f[i][1]=f[1][i]=1,f[i][j]=f[i-1][j]+f[i][j-1],求f[n][n].C++代码: #include <iostream> using namespace std; int n, f[11][11]; int main() { cin >> n; for (int i=1;i<=n;i++) f[i][1] = f[1][

codeforces水题100道 第十四题 Codeforces Round #321 (Div. 2) A. Kefa and First Steps (brute force)

题目链接:http://www.codeforces.com/problemset/problem/580/A题意:求最长连续非降子序列的长度.C++代码: #include <iostream> using namespace std; const int maxn = 100100; int n, a[maxn], tmp, ans; int main() { cin >> n; for (int i = 0; i < n; i ++) cin >> a[i]

codeforces水题100道 第十五题 Codeforces Round #262 (Div. 2) A. Vasya and Socks (brute force)

题目链接:http://www.codeforces.com/problemset/problem/460/A题意:Vasya每天用掉一双袜子,她妈妈每m天给他送一双袜子,Vasya一开始有n双袜子,请问第几天的时候Vasya会没有袜子穿?C++代码: #include <iostream> using namespace std; int n, m; int main() { cin >> n >> m; int d = 0; while (n) { d ++; if

codeforces水题100道 第十二题 Codeforces Beta Round #91 (Div. 2 Only) A. Lucky Division (brute force)

题目链接:http://www.codeforces.com/problemset/problem/122/A题意:判断一个数是否能被一个lucky number整除,一个lucky number是一个只包含4或7的数.C++代码: #include <cstdio> int lucky[14] = {4, 7, 44, 47, 74, 77, 444, 447, 474, 477, 744, 747, 774, 777}; bool check(int x) { for (int i = 0