Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "pch.h"
- #include <iostream>
- #include <fstream>
- #include <iomanip>
- #include <string>
- using namespace std;
- int sunkiausia();
- int keliosSunk(int sunk);
- int main()
- {
- int kiekLengv = 0;
- int sunk = 0;
- sunk = sunkiausia();
- kiekLengv = keliosSunk(sunk);
- ofstream rrez("rez.txt");
- rrez << sunk << " " << kiekLengv << endl;
- rrez.close();
- }
- int sunkiausia()
- {
- int n = 0, sk = 0, did = 0;
- ifstream d("duom2.txt");
- d >> n;
- for (int i = 0; i < n; i++)
- {
- d >> sk;
- if (sk > did) did = sk;
- }
- return did;
- d.close();
- }
- int keliosSunk(int sunk)
- {
- int n = 0, kiek = 0, sk = 0;
- ifstream d("duom2.txt");
- d >> n;
- for (int i = 0; i < n; i++)
- {
- d >> sk;
- if (sk * 2 <= sunk) kiek++;
- }
- return kiek;
- d.close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement