Uppercase and lowercase letters exchange conversion

Topic Description:
In the process of learning English, the English letter case in some situations is the need to meet certain requirements.
For example, when the representation of names, often the first letter of the name of the capital you need to express.
Now, I would like you to complete a modified-sensitive functions:

Next will enter an uppercase and a lowercase letter,
you exchange these two letters,
and are converted each case.
Input format:
Enter one capital letter and one lowercase letter.

Output format:
output in a capital letter after the modification required, and a lowercase letter.

样例:
input
A c
output
C a

#include <iostream>
#include <cstdio>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

void xxx(char c)
{
	if((c>='A')&&(c<='Z')) 
	{
		c+=32;//判断是否为大写字母,是则转换为小写字母。
	}
	else if((c>='a')&&(c<='z')) 
	{
		c-=32;//否则判断是否为小写字母,是则转换为大写字母。
	}
	cout<<c;
}

int main(int argc, char** argv) {
	
	char a,b;
	cin>>a>>b;
	xxx(b);//a.b交换顺序输出 
	cout<<" ";
	xxx(a);
	
	return 0;
}
Released three original articles · won praise 45 · views 1378

Guess you like

Origin blog.csdn.net/Joseph_tony/article/details/105290903