Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Zadanie domode wektor A(n).cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #include <iostream>
- #include <math.h>
- using namespace std;
- int main()
- {
- float suma = 0;
- float srednia = 0;
- int ilosc,i;
- float suma1, srednia1,odchylenie;
- suma1 = 0;
- srednia1 = 0;
- odchylenie = 0;
- i = 0;
- cout << "podaj ilosc elementow" << endl;
- cin >> ilosc;
- float*wektor = new float[ilosc];
- /*cout << "podaj pierwszy element" << endl;
- cin >> wektor[0];
- cout << "podaj 4 element" << endl;
- cin >> wektor[3];
- cout << "pierwszy element wektora to " << wektor[0] << endl;
- cout << "4 element wektora to " << wektor[3] << endl;*/
- do
- {
- cout << "podaj " << i + 1 << " element wektora" << endl;
- cin >> wektor[i];
- suma = suma + wektor[i];
- i++;
- } while (i + 1 <= ilosc);
- srednia = suma / ilosc;
- cout << "srednia wektora to: " << srednia << endl;
- int a = 0; //obliczanie odchylenia standardowego
- do
- {
- suma1=suma1+(wektor[a] - srednia)*(wektor[a] - srednia);
- a++;
- } while (a < ilosc);
- odchylenie = sqrt(suma1 / ilosc);
- cout << "odchylenie standardowe= " << odchylenie << endl;
- int c = 0;
- while (c < ilosc)
- {
- if (wektor[c] > srednia+0.2*srednia)
- {
- cout << c + 1 << " Element wektora jest wiekszy od sredniej o 20%" << endl;
- }
- c++;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement