C语言怎么样让数字互换位置?
#include <iostream>#include <stdio.h>#include <assert.h>#include <string.h>using namespace std;
void ReverseString(char *szRes,char **szDes){ int uLen=strlen(szRes); char *p1=szRes+uLen-1; char *p2=new char[uLen+1](); assert(p2); *szDes=p2;
while (p1!=szRes) *(p2++)=*(p1--); *(p2++)=*p1; *p2=0; return;}
void main(){ char *p="513546"; char *p2=NULL; ReverseString(p,&p2); cout<<p2<<endl; delete[] p2;}
标签:C语言,互换
版权声明:文章由 酷百书 整理收集,来源于互联网或者用户投稿,如有侵权,请联系我们,我们会立即处理。如转载请保留本文链接:https://www.kubaishu.com/answer/168119.html