#50202: 不用sort(a,b,c) (求救)


h1130130@stu.wghs.tp.edu.tw (二丁33林以寬Ian)

學校 : 不指定學校
編號 : 313931
來源 : [60.248.154.139]
最後登入時間 :
2025-08-20 12:52:56

#include <bits/stdc++.h>
using namespace std;

int main() 
{
  vector<string> neg;
  vector<string> pos;
  string input;
  int a;
  while(cin>>a){
    while(a--){
      cin>>input;
      if(input[0]=='-') neg.push_back(input);
      else pos.push_back(input);
    }
    sort(neg.begin(),neg.end(),greater<string>());
    sort(neg.begin(),neg.end());
    for (const auto& s : neg)
        cout << s << endl;
    for (const auto& s : pos)
        cout << s << endl;
    neg.clear();
    pos.clear();
  }
  return 0;
}

#50203: Re: 不用sort(a,b,c) (求救)


asnewchien@gmail.com (david)

學校 : 南投縣立旭光高級中學
編號 : 68108
來源 : [114.42.176.221]
最後登入時間 :
2025-10-04 22:52:03

你這樣 9 大於 11 

建議寫個比較的函數。