小小颜


私信TA

用户名:dotcpp0767341

访问量:142

签 名:

等  级
排  名 33658
经  验 430
参赛次数 0
文章发表 6
年  龄 0
在职情况 学生
学  校 长沙师范学院
专  业

  自我简介:

TA的其他文章

解题思路:

注意事项:

参考代码:

#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>

#include <math.h>

float function(float a, float b, float c);

#define find_max(a,b,c) (a>b?(a>c?a:c):(b>c?b:c))//用一个三目运算符

int main()

{

float a = 0;

float b = 0;

float c = 0;

float max = 0;

scanf("%f%f%f", &a, &b, &c);

printf("%.3f\n", function(a, b, c));

printf("%.3f", find_max(a,b,c));

}

float function(float a, float b, float c)

{

float ret = 0;

float max = 0;

if (a < b)

{

max = b;

}

else

{

max = a;

}

if (max < c)

{

ret = c;

}

else

{

ret = max;

}

return ret;//保证函数的单一出口性

}


 

0.0分

0 人评分

  评论区

  • «
  • »