竞赛讨论区 > 【题目I】OJ在线编程常见输入输出练习场
头像
Suitieee
发布于 2020-02-26 13:47
+ 关注

【题目I】OJ在线编程常见输入输出练习场

#include <iostream>
using namespace std;
int main(){
    int i, j,num=0;
    string a[100];
    while(cin>>a[num++]){
        if(getchar()!='\n') continue;
        else{
            for(i=0; i<num-1; i++)
                for(j=0; j<num-1-i; j++)
                    if(a[j] > a[j+1]){
                        string temp = a[j];
                        a[j] = a[j+1];
                        a[j+1] = temp;
                    }
            for(i=0; i<num; i++)
                cout << a[i] << ' ';
            cout<<endl;
            num=0;
        }
    }
    return 0;
}


全部评论

(0) 回帖
加载中...
话题 回帖