C ++; array和std dev;很容易解决我确定

时间:2014-07-24 19:19:20

标签: c++

现在我无法编译。这是代码...从键盘读入一组数字并输出std dev。错误代码:LINK:致命错误LNK1104:无法打开文件'c:\ users \ svc-student \ documents \ visual studio 2012 \ Projects \ Lab7ProgProj4 \ Debug \ Lab7ProgProj4.exe'

#include <fstream>
#include <iostream>
#include <cmath>
using namespace std;
double std_dev( double a [], int x );
const int MAX= 100;

int main ()
{
    double next;
    int index = 0;
    double a[MAX];

    cout << "I will give you the std deviation of a group of numbers less than "<< MAX << endl;
    cin >> next;
    while ((cin>>next) && (index < MAX))
    {
        a[index] = next;
        index++;
        cin >> next;
    }
    std_dev ( a , index );
}
double std_dev( double a [], int x )
{
    double average, y;
    double sum = 0;
    int i;
    for( i = 0; i < x;i++ )
        {
        sum = sum + a[i];
        }
    average = sum / x;
    sum = 0;
    for( i = 0; i < x; i++ )
    {
        y =pow((a[i]-average),2);
        //cout << s<<" ";
        sum = sum + y;
    }
cout <<(sqrt (sum / x));

return 0;
}

1 个答案:

答案 0 :(得分:0)

与C ++无关。程序编译。

错误:无法打开文件&c; \ users \ svc-student \ documents \ visual studio 2012 \ Projects \ Lab7ProgProj4 \ Debug \ Lab7ProgProj4.exe&#39;

检查你是否可以在那里写文件,你没有空间。