int main()
{
int n, inInt;
vector <int> list;
ifstream ifs("1.txt");
float a;
ifs >> a;
std::vector<int> result;
int temp;
while(! ifs.eof())
{
ifs >> temp;
result.push_back(temp);
}
int b;
b = result.size();
float array[b+1];
int i;
array[0] = a;
for(i = 1;i < b+1;i++) {
array[i] = (array[i-1] + result[i]-2*array[i-1] * result[i]/a);
}
cout << array[b];
system("pause");
return 0;}
基本上在我的代碼中,我構建了一個向量並構建一個數組,並嘗試使用數組中的向量中的數據。但是,當我編寫代碼時,它給了我一個巨大的錯誤數。C++矢量數組錯誤
請不要修改你的問題,使現有的答案是錯誤的。如果答案解決了最初的問題,但是您遇到了一個無法解決的新問題,請發佈一個新問題。 – ChrisF