关于c++的一道简单题

来源:百度知道 编辑:UC知道 时间:2024/06/06 06:01:55
题目:字母转换
Input:大写字母C
Output:C的小写字母
Sample input:
A
Sample output:
a
Source

下面为大小写互换!输入大写输出小写,输入小写输出大写!
#include<cctype>
#include<iostream>
using namespace std;
void main()
{
char c;
cin>>c;
if (isupper(c))
{
cout<<(char)(c+32)<<endl;
}
else
{
cout<<(char)(c-32)<<endl;
}
}

对应字母加32就可以了,自己动手写程序吧,很简单的。

# include<iostream.h>
void main(void)
{
char n;
cout<<"Please input the char(A-z):"<<endl;
cin>>n;
char temp=n+32;
cout<<"The exchange char is :"<<endl;
cout<<temp<<endl;

}

#include "stdio.h"
int main()
{
printf("请输入大写字母,然后回车: \n");
char c1,c2;
c1=getchar();
c2=c1+32;
printf("%c",c2);
getchar();
getchar();
}

输入大写字母,按回车,即可转换为小写字母..