error C2064: 项不会计算为接受 1 个参数的函数
答案:3 悬赏:20 手机版
解决时间 2021-11-16 04:40
- 提问者网友:临风不自傲
- 2021-11-15 05:19
error C2064: 项不会计算为接受 1 个参数的函数
最佳答案
- 五星知识达人网友:野味小生
- 2021-11-15 05:58
具体程序如下:
void CalculateObjectValue(void)
{
int i;
long temp1,temp2,temp3;
double x1,x2;
for(i=0;i {
temp1=DecodeChromosome(population[i].chrom,0,LENGTH1);
temp2=DecodeChromosome(population[i].chrom,0,LENGTH2);
x1=4.096*temp1/1023.0-2.048;
x2=4.096*temp2/1023.0-2.048;
temp3=100*(x1*x1-x2)*(x1*x1-x2)+(1-x1)(1-x1);
population[i].value=temp3;
}
}
显示的错误位置是: temp3=100*(x1*x1-x2)*(x1*x1-x2)+(1-x1)(1-x1);
请高手指教,分数不是问题,只要是正确答案,分数你自己说要多少就是多少(我自己所有的最高分哦)long DecodeChromosome(char * string ,int point ,int length)
{
int i;
long decimal=0;
char *pointer;
for(i=0,pointer=string+point;i {
decimal+=(*pointer-'0')<<(length-1-i);
}
return(decimal);
}
void CalculateObjectValue(void)
{
int i;
long temp1,temp2,temp3;
double x1,x2;
for(i=0;i
temp1=DecodeChromosome(population[i].chrom,0,LENGTH1);
temp2=DecodeChromosome(population[i].chrom,0,LENGTH2);
x1=4.096*temp1/1023.0-2.048;
x2=4.096*temp2/1023.0-2.048;
temp3=100*(x1*x1-x2)*(x1*x1-x2)+(1-x1)(1-x1);
population[i].value=temp3;
}
}
显示的错误位置是: temp3=100*(x1*x1-x2)*(x1*x1-x2)+(1-x1)(1-x1);
请高手指教,分数不是问题,只要是正确答案,分数你自己说要多少就是多少(我自己所有的最高分哦)long DecodeChromosome(char * string ,int point ,int length)
{
int i;
long decimal=0;
char *pointer;
for(i=0,pointer=string+point;i
decimal+=(*pointer-'0')<<(length-1-i);
}
return(decimal);
}
全部回答
- 1楼网友:往事隔山水
- 2021-11-15 08:55
temp3=100*(x1*x1-x2)*(x1*x1-x2)+(1-x1)(1-x1);
这里不应该有什么错误。
你应该检查一下函数DecodeChromosome定义的参数,与你传入的变量类型有没有不一致。
还有就是检查一下population[i]中的成员函数和变量的定义与实际使用有没有问题
这里不应该有什么错误。
你应该检查一下函数DecodeChromosome定义的参数,与你传入的变量类型有没有不一致。
还有就是检查一下population[i]中的成员函数和变量的定义与实际使用有没有问题
- 2楼网友:迷人又混蛋
- 2021-11-15 07:18
temp3=100*(x1*x1-x2)*(x1*x1-x2)+(1-x1)(1-x1),错误就在这里,应该是:
temp3 = 100*(x1*x1-x2)*(x1*x1-x2)+(1-x1)*(1-x1),最后这个括号前少了个乘法符号
temp3 = 100*(x1*x1-x2)*(x1*x1-x2)+(1-x1)*(1-x1),最后这个括号前少了个乘法符号
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯