当前所在位置:珠峰网资料 >> 计算机 >> 计算机等级考试 >> 正文
2015年计算机二级C++辅导实例编程(7)
发布时间:2010/12/22 15:48:04 来源:城市学习网 编辑:ziteng

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

  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 }

广告合作:400-664-0084 全国热线:400-664-0084
Copyright 2010 - 2017 www.my8848.com 珠峰网 粤ICP备15066211号
珠峰网 版权所有 All Rights Reserved