Laitofai

1d (не 2d, Блять)

Nov 20th, 2018
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1. //#1d
  2. #include <iostream>
  3. #include <fstream>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     ifstream fin("Input.txt");
  10.     if(fin.is_open() == 0){
  11.         cout << "Bad file!";
  12.         return 0;
  13.     }
  14.     //ofstream fout("output.txt");
  15.     double mx = -9223372036854775808, mn = 9223372036854775807, temp;
  16.     while(fin >> temp){
  17.         if(temp >= 0){ //если число положительное
  18.             if(temp < mn){ //если новое число меньще минимального из предыдущих
  19.                 mn = temp;
  20.             }
  21.         }else{ //число отрицательное
  22.             if(temp > mx){
  23.                 mx = temp;
  24.             }
  25.         }
  26.     }
  27.     cout << mx << " " << mn;
  28.     return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment