我一直在做一个问题。因为我得到一个错误,我没有在这里写的功能代码:对于数组下标,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'。 –