zoukankan      html  css  js  c++  java
  • 比较两个数大小并返回(不许使用内置方法或者排序)

    • 比较两个整数并返回较小的
    1 public static int Min(int a, int b)
    2 {
    3     long l1 = (long)a;
    4     long l2 = (long)b;
    5     return (int)((l1 + l2 - Math.Abs(l1 - l2)) / 2);
    6 }
    •  比较两个float类型的数并返回较大的
    1 public static float Max(float a, float b)
    2 {
    3     double d1 = (double)a;
    4     double d2 = (double)b;
    5     return (float)((d1 + d2 + Math.Abs(d1 - d2)) / 2);
    6 }
  • 相关阅读:
    npm
    模块化开发
    Html input 标签
    H5 移动端布局
    Mysql指令
    php面向对象
    git指令
    css3 属性
    如何渲染数据
    angular 服务
  • 原文地址:https://www.cnblogs.com/panchunting/p/interview_tech_algorithm_001.html
Copyright © 2011-2022 走看看