xotohop

файлы_1

May 8th, 2020
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.53 KB | None | 0 0
  1. #include <fstream>
  2. using namespace std;
  3. int main()
  4. {
  5.     int sum = 0;
  6.     int min = INT_MAX, max = INT_MIN;
  7.     ifstream in1("input.txt");
  8.     while (in1.peek() != EOF)
  9.     {
  10.         int t;
  11.         in1 >> t;
  12.         if (t > max)
  13.             max = t;
  14.         if (t < min)
  15.             min = t;
  16.     }
  17.     in1.close();
  18.     ifstream in2("input.txt");
  19.     printf("%d %d\n", max, min);
  20.     while (in2.peek() != EOF)
  21.     {
  22.         int t;
  23.         in2 >> t;
  24.         if (t < max - min)
  25.             sum += t;
  26.     }
  27.     in2.close();
  28.     ofstream out("output.txt");
  29.     out << sum;
  30.     out.close();
  31. }
Add Comment
Please, Sign In to add comment