【发布时间】:2018-07-24 12:10:02
【问题描述】:
我正在开发一个读取 20 SAT 分数的程序。分数将被读取并存储到二维数组中。我写了两种我认为是我的问题的根源的方法。我确定的一个是计算 STD 函数。我收到错误消息:
1 [main] satscores_proj1 1920 cygwin_exception::open_stackdumpfile:将堆栈跟踪转储到 satscores_proj1.exe.stackdump
我正在使用带有 cygwin 编译器包的 netbeans,但是当我尝试使用 DevC++ 运行它时,弹出以下消息:
C:\Dev-Cpp\HW Assignments\satScores.cpp 在函数void compute_std(int (*)[2], int, int, double&, double&)' call of overloadedpow(int, int)' 是不明确的
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <string>
#include <fstream>
#include <cmath>
#include <cctype>
using namespace std;
int main()
{
int sat[10][2], mathAvg, verbAvg;
double mathStd, verbStd;
void describe_program();
void read_scores(int sat[10][2]);
void compute_means(int sat[10][2], int& mathAvg, int& verbAvg);
void compute_std(int sat[10][2],int mathAvg, int verbAvg, double& mathStd, double& verbStd) ;
void show_results(int sat[10][2], int mathAvg, int verbAvg, double mathStd, double verbstd);
bool again();
describe_program();
read_scores(sat);
compute_means(sat, mathAvg, verbAvg);
compute_std(sat, mathAvg, verbAvg, mathStd, verbStd);
//show_results(sat, mathAvg, verbAvg, mathStd, verbStd);
//again();
return 0;
}
/*
*
*/
void compute_means(int sat[10][2], int& mathAvg, int& verbAvg)
{
int mathScoreSum =0;
int mathCount = 0;
int verbScoreSum = 0;
int verbCount = 0;
for(int i = 0; i<10; i++)
{
for(int j = 0; i<2; j++)
{
if(j==0){
mathScoreSum += sat[i][j];
mathCount++;
}
else{
verbScoreSum += sat[i][j];
verbCount++;
}
}
}
mathAvg = mathScoreSum / mathCount;
verbAvg = verbScoreSum / verbCount;
}
void compute_std(int sat[10][2],int mathAvg, int verbAvg, double& mathStd, double& verbStd)
{
double mathVariance = 0;
double verbVariance = 0;
for(int i = 0; i<10; i++)
{
for(int j = 0; i<2; j++)
{
if(j==0){
mathVariance += pow((sat[i][j] - mathAvg), 2);
}
else{
verbVariance += pow((sat[i][j] - mathAvg), 2);
}
mathStd = sqrt(mathVariance/9);
verbStd = sqrt(verbVariance/9);
}
}
}
有人熟悉这两个错误吗?
【问题讨论】:
-
是时候加载你的调试器了。
标签: c++ function math netbeans dev-c++