C/C++の宿題片付けます 147代目
■ このスレッドは過去ログ倉庫に格納されています
0556デフォルトの名無しさん
2011/04/29(金) 18:02:03.82#include<string>
#include<set>
struct less{
static bool flag;
bool operator()(const std::string &x, const std::string &y) const{
return flag ? x < y : y < x;
}
};
bool less::flag = false;
int main(int argc, char* argv[]){
less::flag = argc < 2;
std::multiset<std::string, less> dic;
for(std::string str; std::getline(std::cin, str);)
dic.insert(str);
for(std::multiset<std::string, less>::iterator it = dic.begin(); it != dic.end(); ++it)
std::cout << *it << std::endl;
}
std::sort禁止じゃないし
やっぱCなんだろうな
■ このスレッドは過去ログ倉庫に格納されています