當前位置:編程學習大全網 - 網站源碼 - 用c語言編寫函數void reverse (string &s),用遞歸法是字符竄s倒序

用c語言編寫函數void reverse (string &s),用遞歸法是字符竄s倒序

#include<iostream.h>

#include<string.h>

void reverse (char *s)

{

char t;

static int i=0;

t = *(s+strlen(s)-i-1);

*(s+strlen(s)-i-1) = *(s+i);

*(s+i) = t;

i++;

if(strlen(s)/2==i);

else reverse (s);

}

void main()

{

char s[100];

cin>>s;

reverse(s);

cout<<s<<endl;

}

  • 上一篇:紅包求助CE過木馬加載
  • 下一篇:鼓浪嶼信息
  • copyright 2024編程學習大全網