嗨是的我在使用以下代码时遇到了一些麻烦.上面的函数执行并输出132.87到float变量但是当我将它返回到主程序时,输出则缩短为132.00
这显然是我想念的一些简单的事可以帮助我吗?非常感激.
calcSigmaXY(max) {
int count= 0;
float runTotal = 0, product[max];
for (count = 1; count <= max; count++) {
product[count] = pointData[count][1] * pointData[count][2];
runTotal = runTotal + product[count];
}
printf("\nruntotal is %4.2f",runTotal); // outputs 132.87
return(runTotal);
}
int maxPoints = 6;
float sigmaXY = 0,
sigmaXY = calcSigmaXY(maxPoints);
printf("\nsigmaxy set to : %4.2f\n", sigmaXY); // outputs 132.00
Run Code Online (Sandbox Code Playgroud)