如何定义min或max以确定两个数字或数组中的最小值?

huangapple go评论55阅读模式
英文:

How to define min or max to determine the minimum value between tow numbers or in array?

问题

I have recently defined a code for a problem in CPLEX and I have encountered a syntax error when I wanted to get the minimum value in an array. please see the code provided below as an example.

float Y = min (2.3, 3, 4, 2, 13, 45)

I got this error: syntax error, unexpected ',', expecting in

英文:

I have recently defined a code for a problem in CPLEX and I have encountered a syntax error when I wanted to get the minimum value in an array. please see the code provided below as an example.

float Y = min (2.3, 3, 4, 2, 13, 45)

I got this error: syntax error, unexpected ',', expecting in

答案1

得分: 0

你可以使用 minl 函数:

float Y = minl(2.3, 3, 4, 2, 13, 45);

execute
{
  writeln(Y);
}

结果是:

2
英文:

You can use minl

float Y = minl (2.3, 3, 4, 2, 13, 45);

execute
{
  writeln(Y);
}

gives

2

huangapple
  • 本文由 发表于 2023年5月22日 15:02:48
  • 转载请务必保留本文链接:https://go.coder-hub.com/76303704.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定