【发布时间】:2015-02-09 21:50:22
【问题描述】:
我的问题是当我运行我的程序时,它告诉我“运行时检查失败 #2 - 围绕变量 'RL' 的堆栈已损坏。”
#include<iostream>
double current(double Eth, double Rth, double RL[], int j);
double power(double I[], int k, double RL[], int j);
int main()
{
using namespace std;
double Eth, Rth, RL[100], I[100], P[100], Pmax;
Pmax = 0;
cout << "enter the values of Eth and Rth respectively " << endl;
cin >> Eth >> Rth;
int j = 0;
for (int i = (Rth / 10); i <= Rth * 10; i = i + 0.25)
{
RL[j] = i;
I[j] = current(Eth, Rth, RL, j);
P[j] = power(I, j, RL, j);
if (P[j]> Pmax)
Pmax = P[j];
j++;
}
cout << " the max power =" << Pmax << endl;
return 0;
}
double current(double Eth, double Rth, double RL[], int j)
{
double IL;
IL = (Eth / (RL[j] * Rth));
return IL;
}
double power(double I[], int k, double RL[], int j)
{
double Pow;
Pow = I[k] * I[k] * RL[j];
return Pow;
}
【问题讨论】:
-
请更改您的标题。