大小写转换
Time Limit: 1000 ms Memory Limit: 65536 KiB
Problem Description
X现在要学习英文以及各种稀奇古怪的字符的了。现在他想把一串字符中的小写字母变成大写字符,大写字母变成小写字母,其他的保持不变。
Input
输入有多组。
每组输入一个字符串,长度不大于80,不包含空格。
Output
输出转换后的字符串
Sample Input
A*
B+
Sample Output
a*
b+
Hint
Source
zmx
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace test1
{
class Program
{
static void Main(string[] args)
{
string s;
while ((s = Console.ReadLine()) != string.Empty)
{
char[] a = s.ToCharArray();
int i;
for (i = 0; i < s.Length; i++)
{
if (a[i] >= 'a' && a[i] <= 'z')
{
a[i] = (char)(a[i] - 32);
}
else if (a[i] >= 'A' && a[i] <= 'Z')
{
a[i] = (char)(a[i] + 32);
}
}
Console.WriteLine(a);
}
}
}
}