| « | November 2025 | » | | 日 | 一 | 二 | 三 | 四 | 五 | 六 | | | | | | | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 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....... |
|
|