字符串——首字符大写
#include <stdio.h> #include <iostream> #include <string> #include <cstring> using namespace std; int main(){ string str; getline(cin,str); for(int i = 0; i < str.size();i++){ if(i == 0) str[i] -= 32; if(i > 0 && str[i-1] == ' ') str[i] -= 32; } cout<<str<<endl; return 0; }