Advertisement
MariusPure

2016 1

May 29th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.77 KB | None | 0 0
  1. #include "pch.h"
  2. #include <iostream>
  3. #include <fstream>
  4. #include <iomanip>
  5. #include <string>
  6. using namespace std;
  7.  
  8. int sunkiausia();
  9. int keliosSunk(int sunk);
  10.  
  11. int main()
  12. {
  13.     int kiekLengv = 0;
  14.     int sunk = 0;
  15.     sunk = sunkiausia();
  16.     kiekLengv = keliosSunk(sunk);
  17.     ofstream rrez("rez.txt");
  18.     rrez << sunk << " " << kiekLengv << endl;
  19.     rrez.close();
  20.  
  21.  
  22. }
  23. int sunkiausia()
  24. {
  25.     int n = 0, sk = 0, did = 0;
  26.     ifstream d("duom2.txt");
  27.     d >> n;
  28.  
  29.     for (int i = 0; i < n; i++)
  30.     {
  31.         d >> sk;
  32.         if (sk > did) did = sk;
  33.     }
  34.     return did;
  35.     d.close();
  36. }
  37.  
  38. int keliosSunk(int sunk)
  39. {
  40.     int n = 0, kiek = 0, sk = 0;
  41.     ifstream d("duom2.txt");
  42.     d >> n;
  43.     for (int i = 0; i < n; i++)
  44.     {
  45.         d >> sk;
  46.         if (sk * 2 <= sunk) kiek++;
  47.     }
  48.  
  49.     return kiek;
  50.     d.close();
  51.  
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement