zoukankan      html  css  js  c++  java
  • c语言 8-1

    c语言 8-1

    1、

    #include <stdio.h>
    
    #define diff(x, y) ((x) - (y))
    
    int main(void)
    {
        int a, b;
        puts("please input two integers.");
        printf("a = "); scanf("%d", &a);
        printf("b = "); scanf("%d", &b);
        printf("diff result: %d
    ", diff(a, b));
        
        double m, n;
        puts("please input two doubles.");
        printf("m = "); scanf("%lf", &m);
        printf("n = "); scanf("%lf", &n);
        printf("diff result: %f
    ", diff(m, n));
        
        return 0;
    }

    2、

    #include <stdio.h>
    
    #define diff(x, y)  ((x > y) ? (x - y) : (y - x))
    
    int main(void)
    {
        int a, b;
        puts("please input two integers.");
        printf("a = "); scanf("%d", &a);
        printf("b = "); scanf("%d", &b);
        printf("result: %d
    ", diff(a, b));
        
        double m, n;
        puts("please input two doubles.");
        printf("m = "); scanf("%lf", &m);
        printf("n = "); scanf("%lf", &n);
        printf("result: %f
    ", diff(m, n));
        
        return 0;
    }

  • 相关阅读:
    求算个十百输出
    求算反弹高度
    九九乘法表
    等腰三角形字母
    动态数码管
    静态数码管
    出错的程序操作
    EPLAN
    robotstudio smart组件解释
    eclipse插件安装方法
  • 原文地址:https://www.cnblogs.com/liujiaxin2018/p/14805587.html
Copyright © 2011-2022 走看看