首页 > 试题广场 >

设计函数min(x,y),返回两个double数值中较小的数

[问答题]

设计函数min(x,y),返回两个double数值中较小的数值,同时用一个简单的驱动程序测试该函数。

推荐
#include<stdio.h>
double min(double ,double );
int main(void)
{
 double x,y;
 printf("input two doubles:");
 scanf("%lf%lf",&x,&y);
 printf("the smaller is:%.2lf\n",min(x,y));
 return(0);
}
double min(double a,double b)
{
 return a<b?a:b;
}

发表于 2018-05-05 21:43:12 回复(0)
链接:https://www.nowcoder.com/questionTerminal/2d7793c6367d4be88002320e8f1f474b
来源:牛客网
#include <stdio.h>
doublemin(double,double);
intmain(void)
{
    doublex, y;
    printf("Input two doubles:");
    scanf("%1f%1f", &x, &y); 
    printf("The smaller is %1.2f", min(x, y));
    return0;
}
doublemin(double,double)
{
    doublea, b;
    returna < b ? a :b;
}
发表于 2019-09-30 14:49:08 回复(0)
min是C语言里面的math.h的一个函数  直接用这个做函数名会报错
发表于 2018-10-17 19:42:53 回复(0)
#include <stdio.h>
double min(double, double);
int main(void)
{
    double x, y;
    printf("Input two doubles:");
    scanf("%1f%1f", &x, &y);  
    printf("The smaller is %1.2f", min(x, y));
    return 0;
}
double min(double, double)
{
    double a, b;
    return a < b ? a :b; 
}
编辑于 2018-08-08 13:34:51 回复(0)