大小写转换 (sdut oj)

来源:互联网 发布:java paintcomponent 编辑:程序博客网 时间:2024/06/15 17:14


大小写转换

Time Limit: 1000MS Memory Limit: 65536KB



Problem Description

X现在要学习英文以及各种稀奇古怪的字符的了。现在他想把一串字符中的小写字母变成大写字符,大写字母变成小写字母,其他的保持不变。


Input

 输入有多组。
每组输入一个字符串,长度不大于80,不包含空格。


Output

 输出转换后的字符串


Example Input

A*B+


Example Output

a*b+


Hint

 

Author

 zmx







参考代码


#include<stdio.h>#include<string.h>int main(){    char a[100];    char b[100];    int n;    int i;    while(gets(a) != NULL)    {        n = strlen(a);        for(i = 0; i < n; i++)        {            if(a[i] >= 'a' && a[i] <= 'z')            {                b[i] = a[i] - 32;            }            else if(a[i] >= 'A' && a[i] <= 'Z')            {                b[i] = a[i] + 32;            }            else            {                b[i] = a[i];            }        }        for(i = 0; i < n; i++)        {            printf("%c",b[i]);        }        printf("\n");    }    return 0;}


0 0
原创粉丝点击