判断一个字符(小写变为大写,大写变小写,数字不变,空格输出space,其他字符输出other)C语言

#include<stdio.h>
int main()
{
	char x;
	printf("请输入一个字符:");
	scanf("%c",&x);
	if(x>='a'&&x<='z');//小写转大写
		printf("%c",x-32);
	else if(x>='A'&&x<='Z);//大写转小写
		printf("%c",x+32);
	else if(x>='0'&&x<='9');//数字不变
		printf("%c",x);
	else if(x==' ');//中间为空格
		printf("space");
	else
		printf("other");
} 
发布了18 篇原创文章 · 获赞 1 · 访问量 426

猜你喜欢

转载自blog.csdn.net/qq_43694085/article/details/103770145