算法实现将一个输入的数字颠倒(输入12345->54321)
#include <iostream> char *change(char *str) { int length=strlen(str); int i; char flag; for(i=0;i<length/2;i++) { flag=str[length-1-i]; str[length-1-i]=str[i]; str[i]=flag; } return str; } void main() { char ch[6]="12345"; std::cout<<change(ch); getchar(); }
----转载请注明出处http://www.cnblogs.com/JerryWang1991/ 谢谢!