我一直在做一個問題。因爲我得到一個錯誤,我沒有在這裏寫的功能代碼:對於數組下標,float [int]類型無效
invalid types float[int] for array subscript in the following code snippet.
請告訴我這是爲什麼error
來了嗎?
#include<iostream>
using namespace std;
main()
{
float a,b,p,q,r,s,arr[1000];
int n=1000, minOp;
cin>>a;
cin>>b;
cin>>p>>q>>r>>s;
arr[0]=src;
for(int i=1; i<n; i++)
{
if(i%4==1)
{
a[i]=a[i/4] + p;
}
else if(i%4==2)
{
a[i]=a[i/4] - q;
}
else
if(i%4==3)
{
a[i]=a[i/4] * r;
}
else if(i%4==0)
{
a[i]= a[ (i/4)-1]/s;
}
}
root = buildTree(arr, n);
minOp = bfs(root,b);
cout<<minOp;
}
任何幫助,將不勝感激。
'a'是'float',而不是'float'數組。 – songyuanyao
我懷疑你打算在所有你使用''a''的地方使用'arr'。 –