zoukankan      html  css  js  c++  java
  • CodeForces 131A cAPS lOCK

    cAPS lOCK
    Time Limit:500MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u

    Description

    wHAT DO WE NEED cAPS LOCK FOR?

    Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passage.

    Let's consider that a word has been typed with the Caps lock key accidentally switched on, if:

    • either it only contains uppercase letters;
    • or all letters except for the first one are uppercase.

    In this case we should automatically change the case of all letters. For example, the case of the letters that form words "hELLO", "HTTP", "z" should be changed.

    Write a program that applies the rule mentioned above. If the rule cannot be applied, the program should leave the word unchanged.

    Input

    The first line of the input data contains a word consisting of uppercase and lowercase Latin letters. The word's length is from 1 to 100 characters, inclusive.

    Output

    Print the result of the given word's processing.

    Sample Input

    Input
    cAPS
    Output
    Caps
    Input
    Lock
    Output
    Lock
     1 #include <stdio.h>
     2 #include <string.h>
     3 int main()
     4 {
     5     char a[105];
     6     int i,j,k;
     7     while(scanf("%s",a)!=EOF)
     8     {
     9         int flg=1;
    10         int l=strlen(a);
    11         for(i=1;i<l;i++)
    12         {
    13             if('A'<=a[i] && a[i]<='Z')
    14                 k=1;
    15             else
    16             {
    17                 flg=0;
    18                 break;
    19             }
    20         }
    21         //printf("%d
    ",flg);
    22         if(flg!=1)
    23             printf("%s
    ",a);
    24         else
    25         {
    26             if('A'<=a[0] && a[0]<='Z')
    27                 printf("%c",a[0]+32);
    28             else
    29                 printf("%c",a[0]-32);
    30             for(i=1;i<l;i++)
    31                 printf("%c",a[i]+32);
    32         }
    33         printf("
    ");
    34     }
    35     return 0;
    36 }
    View Code
  • 相关阅读:
    Hive的mysql安装配置
    Linux下的MySQL安装
    Hive的安装与基础指令
    浅谈数据库和数据仓库
    Hive的学习之路(理论篇)
    Spring---bean的命名
    Spring---单例模式(Singleton)的6种实现
    Spring---加载配置文件的几种方法(org.springframework.beans.factory.BeanDefinitionStoreException)
    Spring---配置文件概述
    Spring---Bean生命周期
  • 原文地址:https://www.cnblogs.com/cyd308/p/4771494.html
Copyright © 2011-2022 走看看