Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <gmpxx.h>
- #include <iostream>
- #include <string>
- int main(int argc, char **argv)
- {
- mpz_class d = 20; //dokladnosc
- mpz_class n = 0; //ilosc cyfr
- mpz_class p = 1; //okres
- if(argc > 1)
- {
- d = argv[1];
- }
- std::string sxn;
- mpf_class xn;xn = 0;
- mpf_class xn_sum; xn_sum = 0;
- mpf_class xn_2sum; xn_2sum = 0;
- while(std::cin >> sxn)
- {
- xn = sxn;
- xn_sum += xn;
- xn_2sum += (xn*xn);
- n+=1;
- }
- mpf_class avg = xn_sum / n;
- mpf_class vari = (xn_2sum / n) - avg*avg;
- std::cout << "zadana dokladnosc d=" << d << "\n";
- std::cout << "wpisano n=" << n << " liczb\n";
- std::cout << "srednia= " << avg << "\n";
- std::cout << "wariacja= " << vari << "\n";
- //srednia
- //wariancja
- //okres ciagu
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement