Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <iomanip>
- #include <cmath>
- using namespace std;
- const char CDfd[] = "duom.txt";
- const char CDfr[] = "rez.txt";
- const int CMax = 24;
- void Skaityti (const char CDfd[], int A[], double B[], int& n);
- void Spausdinti (const char CDfr[], int A[], double B[], int n);
- int AuksciausiaTemp (double B[], int n);
- void SpausdintiAukstaTemp (const char CDfr[], int A[], double B[], int n, double max);
- int main()
- {
- int V[CMax];
- double T[CMax];
- int n;
- ofstream fr(CDfr, ios::app);
- Skaityti (CDfd, V, T, n);
- Spausdinti (CDfr, V, T, n);
- int indmax = AuksciausiaTemp (T, n);
- fr << "Auksciausia temperatura " << T[indmax] << " buvo " << V[indmax] << " val." << endl;
- SpausdintiAukstaTemp(CDfr, V, T, n, T[indmax]);
- fr.close();
- return 0;
- }
- void Skaityti (const char CDfd[], int A[], double B[], int& n)
- {
- ifstream fd(CDfd);
- fd >> n;
- for (int i = 0; i < n; i++)
- fd >> A[i] >> B[i];
- fd.close();
- }
- void Spausdinti (const char CDfr[], int A[], double B[], int n)
- {
- ofstream fr(CDfr);
- fr << " Ligonio temperatura " << endl;
- fr << "---------------------" << endl;
- fr << " Valanda Temperatura " << endl;
- fr << "---------------------" << endl;
- for (int i = 0; i < n; i++)
- fr << setw(5) << A[i] << " " << fixed << setw(2) << setprecision(1) << B[i] << endl;
- fr << "---------------------" << endl;
- fr.close();
- }
- int AuksciausiaTemp (double B[], int n)
- {
- double max = B[0];
- int maxind = 0;
- for (int i = 1; i < n; i++)
- if (B[i] > max){
- max = B[i];
- maxind = i;
- }
- return maxind;
- }
- void SpausdintiAukstaTemp (const char CDfr[], int A[], double B[], int n, double max)
- {
- ofstream fr(CDfr, ios::app);
- fr << "Auksta temperatura dar buvo:" << endl;
- for (int i = 0; i < n; i++)
- if (fabs(max - B[i]) <= 0.5)
- fr << A[i] << " val. " << B[i] << endl;
- fr.close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement