返回列表 發帖
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. ifstream ifs;
  4. ofstream ofs;
  5. vector<int> v;
  6. int main()
  7. {
  8.     int n;
  9.     for(int i=0;i<4;i++)
  10.     {
  11.         cin>>n;
  12.         v.push_back(n);
  13.     }
  14.     ifs.open("read.txt");
  15.     ofs.open("write.txt");
  16.     while(ifs>>n)
  17.     {
  18.         v.push_back(n);
  19.     }
  20.     sort(begin(v),end(v));
  21.     for(int i:v)
  22.     {
  23.         cout<<i<<endl;
  24.         ofs<<i<<'\n';
  25.     }

  26. }
複製代碼

TOP

  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. ifstream ifs;
  4. ofstream ofs;
  5. vector<int> v;
  6. int main()
  7. {
  8.     int n;
  9.     for(int i=0;i<4;i++)
  10.     {
  11.         cin>>n;
  12.         v.push_back(n);
  13.     }
  14.     ifs.open("read.txt");
  15.     ofs.open("write.txt");
  16.     while(ifs>>n)
  17.     {
  18.         v.push_back(n);
  19.     }
  20.     sort(begin(v),end(v));
  21.     for(int i:v)
  22.     {
  23.         cout<<i<<endl;
  24.         ofs<<i<<'\n';
  25.     }

  26. }
複製代碼

TOP

返回列表