zoukankan      html  css  js  c++  java
  • [C]分别用函数和带参的宏,求3个数中的最大值

    //带参宏求3个数的最大值
    #include <stdio.h>
    #define MAX(a, b, c) (a>b?a:b)>c?(a>b?a:b):c
    int main()
    {
        int a, b, c;
        puts("input three numbers, use space to seperate each other:");
        scanf("%d%d%d", &a, &b, &c);
        printf("%d
    ", MAX(a,b,c));
        return 0;
    }
    //用函数求三个数的最大值
    #include <stdio.h>
    int MAX(int a, int b, int c); //函数声明
    int main()
    {
        int a, b, c;
        puts("input three numbers, use space to seperate each other:");
        scanf("%d%d%d", &a, &b, &c);
        printf("%d
    ", MAX(a,b,c));
        return 0;
    }
    
    int MAX(int a, int b, int c)
    {
        int max;
        if (a > b)
            max = a;
        else
            max = b;
        if (c > max)
            max = c;
        return max;
    }
    //以上两个方法合起来,投机取巧地采用函数求三个数的最大值
    #include <stdio.h>
    int MAX(int a, int b, int c); //函数声明
    int main()
    {
        int a, b, c;
        puts("input three numbers, use space to seperate each other:");
        scanf("%d%d%d", &a, &b, &c);
        printf("%d
    ", MAX(a,b,c));
        return 0;
    }
    
    int MAX(int a, int b, int c)
    {
        return (a>b?a:b)>c?(a>b?a:b):c;
    }
  • 相关阅读:
    EnumMap实现类
    java enum
    openssl生成RSA公钥和私钥对
    rsa 公钥 私钥
    eclispe 通过git向码云上传
    eclipse git 报 git: 401 Unauthorized
    HttpClient 超时时间
    HttpClient 4 和 HttpClient 3 超时
    Java RSA 生成公钥 私钥
    万能适配器
  • 原文地址:https://www.cnblogs.com/profesor/p/12970506.html
Copyright © 2011-2022 走看看