请问编程提示[Error] 'pow' was not declared in this scope是什么意思,应该怎么改?
intant::ChooseNextCity(){//Updatetheprobabilityofpathselection//selectapathfromtabu[m...
int ant::ChooseNextCity()
{
//Update the probability of path selection
//select a path from tabu[m_iCityCount-1] to next
int i;
int j=10000;
double temp=0;
int curCity=tabu[m_iCityCount-1];
for (i=0;i<iCityCount;i++)
if((AllowedCity[i]==1))
{
temp+=pow(((1.0/Map.distance[curCity][i]),beta)*pow((Map.m_dTrial[curCity][i]),alpha));
}
double sel=0;
for (i=0;i<iCityCount;i++)
if((AllowedCity[i]==1))
{
prob[i]=pow((1.0/Map.distance[curCity][i]),beta)*pow((Map.m_dTrial[curCity][i]),alpha)/temp;
sel+=prob[i];
}
else
prob[i]=0;
double mRate=rnd(0,sel);
double mSelect=0;
for ( i=0;i<iCityCount;i++)
if((AllowedCity[i]==1))
mSelect+=prob[i] ;
if ((mSelect>=mRate)) {j==i;break;}
if (j==10000)
{
temp=-1;
for (i=0;i<iCityCount;i++)
if((AllowedCity[i]==1))
if (temp
{
temp=pow((1.0/Map.distance[curCity][i]),beta)*pow((Map.m_dTrial[curCity][i]),alpha);
j=i;
};
}
return j;
}程序太长,这是中间的一段,带pow的那几行都有[Error] 'pow' was not declared in this scope的问题。我是小白,求大神指教 展开
{
//Update the probability of path selection
//select a path from tabu[m_iCityCount-1] to next
int i;
int j=10000;
double temp=0;
int curCity=tabu[m_iCityCount-1];
for (i=0;i<iCityCount;i++)
if((AllowedCity[i]==1))
{
temp+=pow(((1.0/Map.distance[curCity][i]),beta)*pow((Map.m_dTrial[curCity][i]),alpha));
}
double sel=0;
for (i=0;i<iCityCount;i++)
if((AllowedCity[i]==1))
{
prob[i]=pow((1.0/Map.distance[curCity][i]),beta)*pow((Map.m_dTrial[curCity][i]),alpha)/temp;
sel+=prob[i];
}
else
prob[i]=0;
double mRate=rnd(0,sel);
double mSelect=0;
for ( i=0;i<iCityCount;i++)
if((AllowedCity[i]==1))
mSelect+=prob[i] ;
if ((mSelect>=mRate)) {j==i;break;}
if (j==10000)
{
temp=-1;
for (i=0;i<iCityCount;i++)
if((AllowedCity[i]==1))
if (temp
{
temp=pow((1.0/Map.distance[curCity][i]),beta)*pow((Map.m_dTrial[curCity][i]),alpha);
j=i;
};
}
return j;
}程序太长,这是中间的一段,带pow的那几行都有[Error] 'pow' was not declared in this scope的问题。我是小白,求大神指教 展开
1个回答
展开全部
int main(int argc, char *argv[])
{
int result;
result=add(x);//你的参数x没有定义,或者x应该是一个数值,比如add(5)
printf("%d",result);
}
for(i=1;i<=n;i++)
{
product=product*i;
sum+=product;
printf("sum=%d",sum);//你是说换到这里是吧
add(x);//你的递归没有结束条件
return(x);
}
{
int result;
result=add(x);//你的参数x没有定义,或者x应该是一个数值,比如add(5)
printf("%d",result);
}
for(i=1;i<=n;i++)
{
product=product*i;
sum+=product;
printf("sum=%d",sum);//你是说换到这里是吧
add(x);//你的递归没有结束条件
return(x);
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询