Generation

generate functionSun, 04 Dec 2022

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; } }

Questions about programming?Chat with your personal AI assistant