Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <fstream>
- void funcOne(double **arr, int sizeOne, int SizeTwo);
- void minMax(double **arr, int sizeOne, int SizeTwo);
- int main() {
- std::ifstream in;
- in.open("input_file.txt");
- double D[5][5];
- double element;
- if (in.is_open()) {
- int M = 0;
- int N = 0;
- while (in >> element) {
- if (N == 5 - 1)
- {
- M++;
- }
- D[M][N++] = element;
- }
- }
- in.close();
- funcOne(D, 5, 5);
- minMax(D, 5, 5);
- return 0;
- }
- void funcOne(double **arr, int sizeOne, int SizeTwo)
- {
- double sum = 0;
- int cnt = 0;
- for (int i = 0; i < sizeOne; i++)
- {
- for (int j = 0; j < SizeTwo; j++) {
- if (arr[i][j] > (-5) && arr[i][j] < 5)
- {
- sum = sum + arr[i][j];
- cnt++;
- }
- }
- }
- double sumRes = sum / cnt;
- std::cout << "Sumata ot vs elementi na masiva v diapazona -5 , 5 e : " << sumRes;
- }
- void minMax(double **arr, int sizeOne, int SizeTwo)
- {
- double tmpMin = 0;
- double tmpMax = 0;
- for (int i = 0; i < sizeOne; i++)
- {
- for (int j = 0; j < SizeTwo; j++) {
- if (arr[i][j] < tmpMin)
- {
- tmpMin = arr[i][j];
- }
- if (arr[i][j] > tmpMax)
- {
- tmpMax = arr[i][j];
- }
- }
- }
- double minMaxRes = tmpMax / tmpMin;
- std::cout << "sredno aritmetichno na minimalniq i maksimalniq indeks e : " << minMaxRes;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement