error C2064: 项不会计算为接受 1 个参数的函数

具体程序如下:
void CalculateObjectValue(void)
{
int i;
long temp1,temp2,temp3;
double x1,x2;
for(i=0;i<POPSIZE;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<length;i++,point++)
{
decimal+=(*pointer-'0')<<(length-1-i);
}
return(decimal);
}
这是DecodeChromosome函数,应该没有问题呀!不过还是谢谢你的回答!

具体程序如下:
void CalculateObjectValue(void)
{

nt i;
long temp1,temp2,temp3;

double x1,x2;
for(i=0;i<POPSIZE;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.


控制资料:

花括号内为函数体。

如果没有返回值类型名为"void", 整数类型int 类型返回值为整数类型int,以此类推……

类型名有:void int long float int* long* float* ……

C++中函数的调用:函数必须声明后才可以被调用。调用格式为:函数名(实参)

调用时函数名后的小括号中的实参必须和声明函数时的函数括号中的形参个数相同。

有返回值的函数可以进行计算,也可以做为右值进行赋值。

参考资料来源:百度百科-函数

温馨提示:答案为网友推荐,仅供参考
第1个回答  推荐于2017-10-06
  具体程序如下:
  void CalculateObjectValue(void)
  {
  int i;
  long temp1,temp2,temp3;
  double x1,x2;
  for(i=0;i<POPSIZE;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<length;i++,point++)
  {
  decimal+=(*pointer-'0')<<(length-1-i);
  }
  return(decimal);
  }
第2个回答  推荐于2017-10-14
temp3=100*(x1*x1-x2)*(x1*x1-x2)+(1-x1)(1-x1),错误就在这里,应该是:
temp3 = 100*(x1*x1-x2)*(x1*x1-x2)+(1-x1)*(1-x1),最后这个括号前少了个乘法符号本回答被提问者采纳
第3个回答  2009-06-26
temp3=100*(x1*x1-x2)*(x1*x1-x2)+(1-x1)(1-x1);
这里不应该有什么错误。

你应该检查一下函数DecodeChromosome定义的参数,与你传入的变量类型有没有不一致。

还有就是检查一下population[i]中的成员函数和变量的定义与实际使用有没有问题
第4个回答  2019-03-19
问题出在这里:
你在前面定义了max为char变量,
char
max,min;
后面使用max函数时,编译认为有问题:
result=max(b[b],b[n]);
但有的编译器编译上述代码不会出错,比如bcb