本站首页    管理页面    写新日志    退出


«November 2025»
1
2345678
9101112131415
16171819202122
23242526272829
30


公告
暂无公告...

我的分类(专题)

日志更新

最新评论

留言板

链接


Blog信息
blog名称:
日志总数:16
评论数量:3
留言数量:-1
访问次数:64163
建立时间:2006年5月22日




字符串递归程序
软件技术

ibmsoa 发表于 2006/5/22 15:59:12

我写了一个C++版的程序~  #include   <iostream>#include   <cstring>#include   <cstdlib>using namespace std;static const int maxsize=100;void   reverse(char     *s){                       static   int     len   =   strlen(s);          static   char   *   begin   =   s;          static   char   *   end   =   s   +   len-1;                if(begin   <   end)        {                char   a   =   *begin;//首个字符存在变量a中;                             *begin++   =   *end;//首个字符变成了*end指向的末尾变量,begin++;                             *end   --   =   a; //末尾得知变成了a,end--;                              reverse(s);//继续倒                                 }}   void main(){        char  str[maxsize];  cout<<"please input the name "<<endl;        cin.get(str,maxsize);cin.ignore(2000,'\n');//防止内存溢出  reverse(str);  cout<<str<<endl;  }程序运行实现, 计划怎样修改后再Linux 下运行, Thinking.......


阅读全文(1638) | 回复(0) | 编辑 | 精华
 



发表评论:
昵称:
密码:
主页:
标题:
验证码:  (不区分大小写,请仔细填写,输错需重写评论内容!)



站点首页 | 联系我们 | 博客注册 | 博客登陆

Sponsored By W3CHINA
W3CHINA Blog 0.8 Processed in 0.016 second(s), page refreshed 144796115 times.
《全国人大常委会关于维护互联网安全的决定》  《计算机信息网络国际联网安全保护管理办法》
苏ICP备05006046号