zoukankan      html  css  js  c++  java
  • c语言中定义函数和调用函数(计算两个数中的较小值)

    1、

    #include <stdio.h>
    
    int min2(int a, int b)
    {
        if (a < b)
            return a;
        else
            return b;
    }
    
    int main(void)
    {
        int n1, n2;
        puts("please input two integers!");
        printf("n1 = "); scanf("%d", &n1);
        printf("n2 = "); scanf("%d", &n2);
        
        printf("smaller is: %d", min2(n1, n2));
        return 0;
    }

     ↓

    #include <stdio.h>
    
    int min2(int a, int b)
    {
        int min;
        if (a < b)
            min = a;
        else
            min = b;
        return min;
    }
    
    int main(void)
    {
        int n1, n2;
        puts("please input two integers!");
        printf("n1 = "); scanf("%d", &n1);
        printf("n2 = "); scanf("%d", &n2);
        
        printf("smaller is : %d\n", min2(n1, n2));
        return 0;
    }

    #include <stdio.h>
    
    int min2(int a, int b)
    {
        int min = a;
        if (b < min)
            min = b;
        return min;
    }
    
    int main(void)
    {
        int n1, n2;
        puts("please input two integers.");
        printf("n1 = "); scanf("%d", &n1);
        printf("n2 = "); scanf("%d", &n2);
        
        printf("smaller is: %d\n", min2(n1, n2));
        return 0;
    }

    #include <stdio.h>
    
    int min2(int a, int b)
    {
        return (a > b) ? b : a; 
    }
    
    int main(void)
    {
        int n1, n2;
        puts("please input two integers.");
        printf("n1 = "); scanf("%d", &n1);
        printf("n2 = "); scanf("%d", &n2);
        
        printf("smaller is: %d", min2(n1, n2));
        return 0;
    }
  • 相关阅读:
    Centos 设置默认路由得优先级
    openstack-NUMA排错记录
    openstack -新建project
    As3 常用日期工具
    As3 计算两个日期之间的天数差
    解决Asp.net Mvc返回JsonResult中DateTime类型数据格式的问题
    网盘+SVN
    SQL 并发-转
    工作目录
    Cookie
  • 原文地址:https://www.cnblogs.com/liujiaxin2018/p/14572406.html
Copyright © 2011-2022 走看看