void correcter(string s, int j)
{
string correct;
for (; j < s.length(); j++)
{
if (int(s[j]) != 46){
if (int(s[j]) >= 97 && int(s[j]) <= 122 && i == 0)
{
char a = int(s[j]) - 32;
correct += a;
i++;
}
else if (int(s[j]) >= 65 && int(s[j]) <= 90&&i==0)
{
char a = int(s[j]) + 32;
correct += a;
i++;
}
else if (int(s[j]) >= 65 && int(s[j]) <= 90)
{
char a = int(s[j]) + 32;
correct += a;
i++;
}
else
correct += s[j];
}
else
{
correct += ". ";
i = 0;
}
}
cout << correct << endl;
}
问题是编写一个代码,将字符串的第一个字符转换为大写字母,而其他字符保持小写字母。在每一个“。”之后。先把字再放在上面,其他部分再放低!将小写字母转换为大写字母,并使其他字符保持较低
输入:
hellOWOrLD.hELLOWORLD。
输出:
为HelloWorld。你好,世界。
它应该像图片...
你的问题是?仅供参考:看看'std :: tolower'和'std :: toupper'。 – Rakete1111
以及它只能转换第一或所有字符我的是转换它的第一个字符加上使其他部分的单词小写,如示例input => hellOWOrLD.hELLOWORLD。输出=>为HelloWorld。你好,世界。 –