33,311
社区成员
发帖
与我相关
我的任务
分享
char changeChar(char temp){
temp = temp-'a'+'A';
cout<<"转化后的字母是:"<< temp <<endl;
return temp;
}
#include <iostream>
using namespace std;
char changeChar(char temp)
{
temp=temp-32;//a-A = 32
//temp = temp - 'a' + 'A';
cout<<"转化后的字母是:"<<temp<<endl;
return temp;
}
int main()
{
char temp;
cout<<"请输入一个小写字母:"<<endl;
cin>>temp;
cout<<"输出刚才输入的字母:"<<temp<<endl;
changeChar(temp);
return 0;
}
#include <iostream>
using namespace std;
char changeChar(char temp)
{
temp=temp-'a'+'A';//这里错了。。改成这样。。
cout<<"转化后的字母是:"<<temp<<endl;
return temp;
}
int main()
{
char temp;
cout<<"请输入一个小写字母:"<<endl;
cin>>temp;
cout<<"输出刚才输入的字母:"<<temp<<endl;
changeChar(temp);
return 0;
}