递归实现字符串的逆序存储
#include<iostream>
#include<cstring>
using namespace std;
int i = 0;
void InvertStore(char* a)
{
char ch;
ch = cin.get(); //get可以识别空白符
if(ch!='\n')
{
InvertStore(a);
a[i++]=ch;
}
a[i]='\0';
}
int main()
{
char a[100];
while(1){
InvertStore(a);
if(strcmp(a,"0") == 0){
break;
}
i = 0;
cout<<a<<endl;
}
return 0;
}