Attachment 'liststat.cc'
Download 1 #include <iostream>
2 #include <cmath>
3
4 int main()
5 {
6 double x, n(0), sum(0), sqr(0);
7 while (std::cin >> x) {
8 ++n;
9 sum += x;
10 sqr += x * x;
11 }
12 register const double xbar(sum / n);
13 std::cout.precision(12);
14 std::cout
15 << n << "\n"
16 << xbar << "\n"
17 << std::sqrt(sqr / n - xbar * xbar)
18 << std::endl;
19 }
Attached Files
To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.You are not allowed to attach a file to this page.