键盘输入,大写字母变小写,小写变大写

.编写一个程序,可以一直接收键盘字符,

如果是小写字符就输出对应的大写字符,

如果接收的是大写字符,就输出对应的小写字符,

如果是数字不输出。

#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

void conversion() {
 char input, output;
 while (1) {
  scanf("%c", &input);
  //input = getchar();  两种输入方法均可
  printf("\n");
  if (input <= 90 && input >= 65) {
   output = input + 32;
   printf("变换后:%c\n", output);
  }
  if (input <= 122 && input >= 97) {
   output = input - 32;
   printf("变换后:%c\n", output);
  }
 }
}

int main() {
 conversion();
 system("pause");
 return 0;
}
发布了47 篇原创文章 · 获赞 4 · 访问量 515

猜你喜欢

转载自blog.csdn.net/weixin_45818891/article/details/103047115
今日推荐