C++——ASCII排序

代碼以下:ios

 1 #include <iostream>
 2 #include <string.h>
 3 using namespace std;
 4 int main()
 5 {
 6     char str[]="networks";
 7     int i,j,len;
 8     len=strlen(str);
 9     for(i=0;i<len-1;i++){
10         for(j=i+1;j<len;j++){
11             if(str[i]>str[j]){
12             ch=str[i];
13             str[i]=str[j];
14             str[j]=ch;
15             }
16         }
17     }
18     cout<<str;
19     return 0;
20 }
相關文章
相關標籤/搜索