#include <iostream>
#include <cctype>
#include <string>
using namespace std;
int main()
{
string str;
getline(cin,str);
bool capital=1;
for(int i=0;i<str.size();i++)
{
if(capital) str[i]=toupper(str[i]),capital=0;;
if(str[i]==' ')capital=1;
}
cout<<str<<endl;
system("pause");
return 0;
}华为机试 - 字符串首字母转换成大写
最新推荐文章于 2025-02-27 22:53:06 发布
本文介绍了一段使用C++实现字符串中字符大小写转换的代码,通过获取输入字符串,遍历并判断每个字符,对于大写字母转换为小写,反之亦然,并输出转换后的字符串。
692

被折叠的 条评论
为什么被折叠?



