txtファイルの中身をバブルソートする
#include <iostream> #include <fstream> #include <string> #include <algorithm> int main() { std::ifstream ifs("unsorted.txt"); std::vector<int> v; int buf; while (ifs >> buf) { v.push_back(buf); } std::sort(v.begin(), v.end()); for (int n : v) { std::cout << n << std::endl; } }