gpt4 book ai didi

c - 如何获得C函数的实际输出?

转载 作者:行者123 更新时间:2023-11-30 21:03:38 24 4
gpt4 key购买 nike

我很难从 C 函数获取实际输出。例如:

int max3(int a, int b, int c){
if ((a>b)&&(a>c))
return a;
if ((b>c)&&(b>a))
return b;
return c;
}

您能否告诉我如何指定实际输出(例如工具、算法等)?在上面的示例中,实际输出为 6(在 (a,b,c) = (1,2,6) 的情况下)。非常感谢。

最佳答案

我可能会使用三元运算符来编写它,因为它很简单:

int max3(int a, int b, int c){       
if (a>b)
return (a>c)?a:c;
else
return (b>c)?b:c;
}

关于c - 如何获得C函数的实际输出?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23741474/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com