64,637
社区成员
发帖
与我相关
我的任务
分享
#include <iostream>
#include <string>
#include <cctype>
using namespace std;
int main()
{
char c;
string str;
cout << "Enter a string (q to quit):\n";
cin >> str;
while(str!="q")
{
for(int i=0; i < str.length(); i++)
{
c = toupper(str[i]);
cout << c;
}
cout << endl;
cout << "Next string (q to quit):\n";
cin >> str;
//getline(cin,str); 这个函数要等待2次回车起用
}
cout << "Bye\n";
return 0;
}