[ create a new paste ] login | about

Link: http://codepad.org/204ytqfl    [ raw code | output | fork ]

C++, pasted on Dec 23:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// author: caozhy
#include <iostream>
using namespace std;
float aver(float data[], int n)
{
    float r = 0.0;
    for (int i = 0; i < n; i++)
    {
        r += data[i];
    }
    return r / (float)n;
}
int main()
{
    float arr[10];
    for (int i = 0; i < 10; i++)
    {
        cin >> arr[i];
    }
    cout << aver(arr, 10);
}


Output:
1
nan


Create a new paste based on this one


Comments: