#include <iostream>
#include<string.h>
using namespace std;
#define INITSTRLEN 100
typedef struct
{ char *ch;
int length;
int strsize;
}String;
void initString(String &s)
{ s.ch = new char[INITSTRLEN ]; /*初始化串存储空间*/
s.length = 0; /*初始化串长*/
s.strsize = INITSTRLEN; /*初始化当前存储空间容量*/
}
void turn(String &s,int &i)//算法填写
{
char temp = s.ch[i];
s.ch[i] = s.ch[s.length-i-1];
s.ch[s.length-1-i] = temp;
//cout<<s.ch[i]<<endl;
i++;
if(i<s.length/2)turn(s,i);
}
void list(String s)
{
printf("%s", s.ch);
printf("\n");}
int main(){
String s;int i=0;
initString(s);
printf("please input the string s:\n");
scanf("%s", s.ch);
s.length=strlen(s.ch);
turn(s,i);
list(s);
delete(s.ch);
return 0;
}
|