#include <iostream>using namespace std;int main (){ void swap (char * ); char s1[100] , s2[100] ; cout<<"please input the firsr string:"<<endl; cin>>s1; cout<<"please input the second string:"<<endl; cin>>s2; swap (s1); cout<<"the new first string is:"<<s1<<endl; //这里曾经丢了打印<<s1 swap (s2); cout<<"the new second string is:"<<s2<<endl; //这里曾经丢了打印<<s2 return 0; }void swap (char *s ){ int i , j , n; char temp , *w=s; //这里忘记了给*W赋值 for(n=0;*w !='\0';++n) ++w; for(i=0;i<n-1;++i) for(j=i+1;j<n;++j) if(s[i]>s[j]) { temp=s[i]; s[i]=s[j]; s[j]=temp; }}
http://202.197.191.225:8080/58/text/catalog.htm
转载于:https://www.cnblogs.com/bruceloo/archive/2009/06/03/1495519.html