Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <iomanip>
- using namespace std;
- const char FV[] = "data.txt";
- const char FD[] = "output.txt";
- int a[7];
- int b[7];
- double Vidurkis(int u[], int n);
- void Atmetimas(int u[], int &n);
- void Suvedimas(const char FV[], int a[], int b[], int n);
- int main()
- {
- ifstream in(FV);
- ofstream out(FD);
- int nA, nB, n;
- in >> n;
- nA = n;
- nB = n;
- Suvedimas(FV, a, b, n);
- Atmetimas(a, nA);
- Atmetimas(b, nB);
- double aVid, bVid;
- aVid = Vidurkis(a, nA);
- bVid = Vidurkis(b, nB);
- out << fixed << setprecision(1) << aVid << endl;
- out << fixed << setprecision(1) << bVid << endl;
- }
- void Atmetimas(int u[], int &n)
- {
- int didz = 0;
- int maz = 0;
- for(int i = 0; i < n; i++)
- {
- if(u[i] > u[didz]) didz = i;
- if(u[i] < u[maz]) maz = i;
- }
- u[didz] = u[n - 1];
- n--;
- u[maz] = u[n - 1];
- n--;
- //salinimas//
- }
- void Suvedimas(const char FV[], int a[], int b[], int n)
- {
- ifstream in(FV);
- in >> n;
- for(int i = 0; i < n; i++)
- {
- in >> a[i];
- in >> b[i];
- }
- in.close();
- }
- double Vidurkis(int u[], int n)
- {
- double sum;
- sum = 0;
- for(int i = 0; i < n; i++)
- {
- sum += u[i];
- }
- double vid;
- vid = sum / n;
- return vid;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement