我想知道是否可以检查字符串的一个字母是否大写。其他方式查看它,如果字符串中的所有字母都是大写或小写。例子:
string a = "aaaaAaa";
string b = "AAAAAa";
if(??){ //Cheking if all the string is lowercase
cout << "The string a contain a uppercase letter" << endl;
}
if(??){ //Checking if all the string is uppercase
cout << "The string b contain a lowercase letter" << endl;
}
原文由 user7024664 发布,翻译遵循 CC BY-SA 4.0 许可协议
你可以使用标准算法
std::all_of