C++问题 急急急 在线等!

来源:百度知道 编辑:UC知道 时间:2024/07/02 22:51:50
从键盘输入任意字符,判断该字符的种类,若是大写字母则转换为小写字母,若是小写字母则装换为大写,若是数字原样输出,若是其他字符则统一输出“其他字符”

#include <iostream>
using namespace std;
int main()
{
char s;
cin>>s;
if(s>='a'&&s<='z')
{
cout<<"是小写字母"<<endl;
cout<<char(s-32)<<endl;
}
else
if(s>='A'&&s<='Z')
{
cout<<"是大写字母"<<endl;
cout<<char(s+32)<<endl;
}
else
if(s>='0'&&s<='9')
{
cout<<"是数字"<<endl;
cout<<(char)s<<endl;
}
else
cout<<"其他字符"<<endl;
return 0;
}

//---------------------------------------------------------------------------
#include <cctype>
#include <iostream>

using namespace std;
int main(int argc, char* argv[])
{
char ch;
cin>>ch