Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "pch.h"
- #include <iostream>
- #include <cmath>
- using namespace std;
- double wariancja(double * tab, int ileElementow) {
- double suma=0;
- for (int k = 0; k < ileElementow; k++) {
- suma += *(tab + k);
- }
- double m = suma / ileElementow;
- suma = 0;
- for (int i = 0; i < ileElementow; i++) {
- suma += pow((*(tab + i) - m),2.0);
- }
- return (1 / double(ileElementow))*suma;
- }
- int main()
- {
- int elementy=20;
- bool liczmin=false;
- double * tab = new double[elementy];
- for (int i = 0; i < elementy; i++) {
- *(tab + i) = i;
- }
- double s2=wariancja(tab, elementy);
- cout << s2;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement