C语言使用库函数实现大小写字母转换

功能;多行输入,输入大写字母,返回相应的小写字母;输入小写字母,返回相应的大写字母

需要用到的库函数:

islower() -- 判断是否为小写,是,返回非0,不是,返回0

isupper() -- 判断是否为大写,是,返回非0,不是,返回0

tolower()-- 把大写字母转换为小写字母(输入小写字母的话不会变)

toupper()-- 把小写字母转换为大写字母(输入大写字母的话不会变)

注:需要包含ctype.h头文件

#include 
#include 
int main()
{
	char ch = 0;
	while (scanf("%c", &ch) == 1)
	{
		if (islower(ch))
		{
			printf("%c\n",toupper(ch));
		}
		else if (isupper(ch))
		{
			printf("%c\n",tolower(ch));
		}
	}
	return 0;
}

你可能感兴趣的:(c语言,算法,数据结构)