题解 | #简写单词#
简写单词
https://www.nowcoder.com/practice/0cfa856bf0d649b88f6260d878f35bb4
#include <iostream> #include <cctype> using namespace std; string Toupper_string(string str) { for(int i=0; i<=str.size(); i++){ if(islower(str[i])) str[i]= toupper(str[i]); } return str; } int main() { string str; getline(cin, str); string str_new; if (str.find(' ') == string::npos) { str_new += toupper(str[0]); cout << str_new << endl; return 0; } for (int i = 0; i < str.size(); i++) { if (i == 0) str_new += str[0]; else if (i > 0 && str[i] == ' ') str_new+=str[i+1]; } str_new= Toupper_string(str_new); cout << str_new << endl; return 0; } // 64 位输出请用 printf("%lld")