使用string类型输入一个英文语句,试编写一个函数将语句中所有单词转化为大写字母,并在main函数中输出转换后的英文语句
//用简单的函数就好
#include <iostream>
#include <string>
using namespace std;
//转换为大写字母
string Up(string &s)
{
return strupr(const_cast<char*>(s.c_str()));
}
int main()
{
string s;
getline(cin, s);
s = Up(s);
cout << s << endl;
return 0;
}
#include <iostream>
#include <string>
using namespace std;
//转换为大写字母
string Up(string &s)
{
return strupr(const_cast<char*>(s.c_str()));
}
int main()
{
string s;
getline(cin, s);
s = Up(s);
cout << s << endl;
return 0;
}
//运行结果
温馨提示:答案为网友推荐,仅供参考
第1个回答 2018-03-23
开户行改革开放互惠互利