Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using std::cin; using std::cout; using std::endl;
- int main ()
- {
- //Izracunajmo S_xx
- std::vector<double> x{173,176,189,182,167,183,170,179,177,185,172,163,173,180,165,165,176,170,173,182,180,166,181,170,181,180,183,184,195,170};
- double s(0), x_sr(0);
- //Izracunajmo x_sr
- for (int i=0; i<30; i++) {
- x_sr=x_sr+x[i];
- }
- x_sr=x_sr/30;
- cout << "x_sr: " << x_sr << endl;
- for (int i=0; i<30; i++) {
- s=s+(x_sr-x[i])*(x_sr-x[i]);
- //cout << s << endl;
- }
- cout << "S_xx: " << s << endl;
- //Izracunajmo S_yy
- std::vector<double> y{62,88,83,74,62,64,60,74,64,83,55,48,57,83,65,55,75,64,62,77,72,50,76,58,72,69,75,88,82,60
- };
- s=0;
- double y_sr(0);
- //Izracunajmo y_sr
- for (int i=0; i<30; i++) {
- y_sr=y_sr+y[i];
- }
- y_sr=y_sr/30;
- cout << "y_sr: " << y_sr << endl;
- for (int i=0; i<30; i++) {
- s=s+(y_sr-y[i])*(y_sr-y[i]);
- //cout << s << endl;
- }
- cout << "S_yy: " << s << endl;
- //Izracunajmo S_xy
- s=0;
- for (int i=0; i<30; i++) {
- s=s+(x_sr-x[i])*(y_sr-y[i]);
- //cout << s << endl;
- }
- cout << "S_xy: " << s << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement