赞
踩
有5个字符串,要求把字符串从小到大顺序排列,用string方法。
-
-
- string s[5];
- int a=4 ,b=0;
- for(int i=0;i<5;i++){
- cin>>s[i];
- }
- for(int i=0;i<4;i++)
- {
- for(int j=0;j<4;j++){
- if(s[j]>s[j+1]){
- string temp=s[j];
- s[j]=s[j+1];
- s[j+1]=temp;
- }
- }
- }
- for (int i=0;i<5;i++){
- cout << s[i] << " " ;
- }
-
-

Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。