回复 9楼 chenwei435
楼主的要电话号码 有意向就加我吧1273203953 我叫 赵朋
程序代码:#include <stdio.h>
#define SIZE 100
void swap(char *a, char *b)
{
char c;
c = *a;
*a = *b;
*b = c;
}
void convert(char *s)
{
char *p=s,c;
// int i;
while(*p) p++;
//_______________;
//swap(p, p-1);
*p=*(p-1), *(p-1)=0;
if(s<p)
{
c=*s;
*s=*p;
*p=c;
convert(s+1);
//____________;
//swap(p, p-1);
*(p-1)=*p, *p=0;
}
}
int main(void)
{
char string[SIZE]={0};
gets(string);
convert(string);
puts(string);
}
程序代码:#include <stdio.h>
#define SIZE 100
void swap(char *a, char *b)
{
char c;
c = *a;
*a = *b;
*b = c;
}
void convert(char *s)
{
char *p=s,c;
// int i;
while(*p) p++;
//_______________;
//swap(p, p-1);
s!=p ? (*p=*(p-1), *(p-1)=0): 1;
if(s<p)
{
c=*s;
*s=*p;
*p=c;
convert(s+1);
//____________;
//swap(p, p-1);
p-s!=1 ? (*(p-1)=*p, *p=0): 1;
}
}
int main(void)
{
char string[SIZE]={0};
gets(string);
convert(string);
puts(string);
}
程序代码:#include<stdio.h>
void convert(char *s)
{
char *p=s,c;
int i;
while(*p) p++;
if(--p > s){i= *s, *s='\0';};//保存并放上一空字符.
if(s<p)
{
c=*s;
*s=*p;
*p=c;
convert(s+1);
*p=i;//恢复之.
}
}
main(){
char buf[80];
while(1==scanf("%79s",buf)) {
printf("convert:\n");
convert(buf);
printf(buf);
printf("\n");
}
}