求助~同一代码,在VC++6.0和VS2008中怎么会有不同?VS2008则不能正常处理~
zzdun 2008-11-18 05:18:36 #include <iostream>
#include <cmath>
int main()
{
using namespace std;
const double dl = 0.10;
const double fl = 0.05;
const int tz = 100;
int n;
float daphne,cleo;
for (n=2;daphne>=cleo;n++)
{
daphne = tz + (tz * dl) * n;
cleo = tz * pow(1+fl,n);
cout << n << "年后,Cleo的投资价格才能超过Daphne的投资价值。\n";
cout << "Daphne此时的投资价值为:" << daphne << endl << "Cleo此时的投资价值为:" << cleo << endl;
}
cin.get();
return 0;
}
在VC++6.0上是没有问题的~~
而在VS2008上则提示
Run-Time Check Failure #3 - The variable 'daphn' is being used without being initialized.
Run-Time Check Failure #3 - The variable 'cle' is being used without being initialized.
强行继续才能得到结果。难道还要在for语句前面添加N=1时的dephne和cleo“初始化”?
-----------------------------------------------------------------------------------------------------------------
#include <iostream>
#include <string>
#include <cmath>
int main()
{
using namespace std;
const int Arsize = 11;
int sales_volume[Arsize];
int sumsv = 0;
string month[] = {"Jan","Feb","Mar","Apr","May","Jun","Jul","AUG","Sep","Oct","Nov","Dec"};
for (int n=1;n <= 12;n++)
{
cout << "请输入" << month[n-1] << "的销售量为:";
cin >> sales_volume[n-1];
sumsv +=sales_volume[n-1];
};
cout << "全年销售C++ for fools的情况如下:\n";
for (int m=1;m <= 12;m++)
cout << month[m-1] << "销售量为:" << sales_volume[m-1] <<endl;
cout << "全年的总销售量为:" << sumsv << endl;
return 0;
}
这题也是!~
在VC++6.0则没有问题~
在VS2008则提示
Run-Time Check Failure #2 - Stack around the variable 'sales_volume' was corrupted.
不解~~~