大家帮忙看看,关于String类型的代码。哈哈,版主再请进、
程序代码:
#include<iostream> #include<string> #include<cctype> using std::cin; using std::cout; using std::endl; using std::string; using string::size_type; int main() { string user; cout<<"Input a sentence, Spaces into ^"<<endl<<endl; cin>>user; user[0]=toupper(user[0]); for (size_type sign=1;sign!=user.size();++sign) { if((user[sign] == '.') || (user[sign] == '?') || (user[sign] == '!')|| (user[sign] == ';')) { user[sign + 1] = toupper(user[sign + 1]); } if(user[sign]=='^') { user[sign]=' '; } } cout<<endl<<user<<endl<<endl; return 0; }
[ 本帖最后由 lerncav 于 2010-8-16 20:24 编辑 ]