Title Requirements:
Enter the code:
#include <iostream> #include <cstdio>using namespace Std;int main () {char str[100]; int i; while (Cin.getline (str,100, ' \ n ')) {for (i=0; str[i]!= '); i++)//capitalize the first letter of each word {if (str[i]!= ') ') {if (str[i]>= ' a ' &&str[i]<= ' Z ') {str[i]-=32; Break } else break; }} for (i=i+1; str[i]!= '; i++)//capitalize the first letter of each word {if (str[i]== ') { if (str[i+1]>= ' a ' &&str[i+1]<= ' z ' &&str[i+1]!= ') str[i+1]-=32; }} for (i=0; str[i]!= '; i++) {if (str[i]>= ' 0 ' &&str[i]<= ' 9 ')//letter + numeric type processing {if (str[i+1]>= ' a ' &&str[i+1]<= ' z ') | | (str[i+1]>= ' A ' &&str[i+1]<= ' Z ')) {COUT<<STR[I]<≪ ' _'; } else cout<<str[i]; } else if ((str[i]>= ' a ' &&str[i]<= ' z ') | | (str[i]>= ' A ' &&str[i]<= ' Z ')) Number + Letter Type processing {if (str[i+1]>= ' 0 ' &&str[i+1]<= ' 9 ') { cout<<str[i]<< ' _ '; } else cout<<str[i]; } else if (str[i]== ' &&str[i+1]== ")//The spacing of multiple spaces is handled {continue;//places that skip spaces directly } else cout<<str[i]; } cout<<endl; } return 0;}
Operation Result:
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Simple processing of---string of OJ brush problem