Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include "math.h"
- using namespace std;
- int main(int argc, char* argv[])
- {
- const int nmax=20;
- float wektor[nmax];
- int a = 1, i;
- float n, suma=0, srednia=0, odchylenie=0, od=0;
- while (1)
- {
- cout << "Podaj wielkosc wektora n zawierajacego wyniki (<=" << nmax << ")" << endl;
- cin >> n;
- if (n > 0 && n <= nmax)
- {
- for (i = 0;i < n;i++)
- {
- cout << "Podaj wynik doswiadczenia [" << i + 1 << "]" << endl;
- cin >> wektor[i];
- suma += wektor[i];
- }
- cout << "Wektor ma postac:" << endl;
- for (i = 0; i < n; i++)
- cout << setw(8) << setprecision(2) << fixed << wektor[i] << " ";
- cout << endl;
- srednia = suma / n;
- cout << "Srednia arytmetyczna liczb w tym wektorze wynosi " << srednia << "" << endl;
- for (i = 0;i < n;i++)
- {
- od += (wektor[i] - srednia) * (wektor[i] - srednia) / n;
- }
- odchylenie = sqrt(od);
- cout << "Odchylenie standardowe wynosi "<<odchylenie <<""<< endl;
- }
- else
- cout << "Zly rozmiar wektora." << endl;
- cout << "Aby ponownie odtworzyc program podaj dowolna liczbe calkowita, zas aby wyjsc z programu podaj 0." << endl;
- cin >> a;
- if (a == 0)
- break;
- return 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement