字符串操作之字母大小写转换(不包含中间插入空格)

版权声明:版权归本站站长所有转载请声明 https://blog.csdn.net/qq_40179458/article/details/85028390
#include<iostream>
using namespace std;

int main()
{
	char a[21];
	scanf("%s", a);
	int l = strlen(a);
	for (int i = 0; i < l; i++)
	{
		if (a[i] >= 'A' && a[i] <= 'Z')
			a[i] += 32;
		else
			a[i] -= 32;
	}
	printf("%s\n", a);
	system("pause");
	return 0;
}

//总结,对于大小写字母转换问题 关键在于要知道大小写字母ASI码间相差32
//即 A+32=a

猜你喜欢

转载自blog.csdn.net/qq_40179458/article/details/85028390