就业数据资源平台
当前位置:首页 > C++语言程序设计
2012年计算机等级二级C++辅导实例编程(7)

输入一个字符串,将其逆序后输出

  01 #include


  02 #include


  03 using namespace std;


  04


  05 void SetStr(string &str)


  06 {


  07 int len=str.length();


  08 char temp;


  09 for (int i=0;i


  10 {//把字符串的两边一一调换


  11 temp=str[i];


  12 str[i]=str[len-1-i];


  13 str[len-1-i]=temp;


  14 }


  15 }


  16


  17 int main()


  18 {


  19 string a;


  20 cout<<"input"<


  21 cin>>a;


  22 SetStr(a);


  23 cout<


  24 return 0;


  25 }

就业数据资源平台