呵呵 也能按字母排名

#include <iostream>
#include <string>
using namespace std;
string str1,str2,str3,z;
int main()
{void exchenge(string *a,string *b);
 string *a,*b,*c;
 cin>>str1>>str2>>str3;
 a=&str1;
 b=&str2;
 c=&str3;
 exchenge(a,b);
 exchenge(a,c);
 exchenge(b,c);
 cout<<str1<<endl;
 cout<<str2<<endl;
 cout<<str3<<endl;
 return 0;
}
void exchenge(string *a,string *b)
{if(*a>*b)
 {z=*a;
  *a=*b;
  *b=z;
 }
posted @ 2012-12-18 19:44  _一千零一夜  阅读(84)  评论(0编辑  收藏  举报