g++无法编译程序,但是在visual studio中和cl编译器都可以正常编译执行。代码如下
#include
#include
#include
using std::string;
using namespace std;
bool hasUppercase(const string& str)
{
for (auto c : str)
if (isupper(c)) return true;
return false;
}
const string& makeLowercase(string& str)
{
for (auto& c : str)
if (isupper(c)) c = tolower(c);
return str;
}
int main()
{
string str;
while(getline(cin,str)){
std::cout << std::boolalpha << hasUppercase(str) << std::endl;
std::cout << makeLowercase(str) << std::endl;
}
}