Java实现分数

2023-10-27

自己独立实现的,如果有bug或者错误,欢迎评论区留言!

文章目录

文档

字段摘要:

修饰符 字段 解释
static final Fraction ONE 分数:1,分子、分母都是1的分数
static final Fraction ZERO 分数:0,分子是0、分母是1的分数

构造方法摘要 :

构造方法 解释
Fraction(String fractionStr) 根据字符串生成一个分数,支持识别”/"、小数点
Fraction(double numerator) 根据一个double数生成一个分数
Fraction(long numerator) 根据一个整型数字生成一个分数;分子式该数字,分母是1
Fraction(long numerator, long denominator) 根据提供的分子、分母生成分数;numerator:分子,denominator:分母

方法摘要 :

修饰符 方法 解释
int intValue() 返回对应分数的int值
long longValue() 返回对应分数的long 值
float floatValue() 返回对应分数的float 值
double doubleValue() 返回对应分数的double 值
int compareTo(Fraction o) 和另一个分数比大小
String toString() 以假分数形式返回分数,使用”/“作为分号
Fraction add(Fraction fraction) 返回两个分数的和,不会改编原分数
Fraction sub(Fraction fraction) 返回两个分数的差,不会改编原分数
Fraction mul(Fraction fraction) 返回两个分数的积,不会改编原分数
Fraction div(Fraction fraction) 返回两个分数的商,不会改编原分数
Fraction clone() 返回一个克隆对象,深拷贝
Fraction getOppositeNumber(Fraction fraction) 返回参数的相反数,a的相反数是-a
Fraction getReciprocal(Fraction fraction) 返回参数的倒数,a的倒数是1/a
boolean isZero() 判断该分数是否为0
long getNumerator() 获取分子
long getDenominator() 获取分母
void setNumerator(long numerator) 设置新的分子
void setDenominator(long denominator) 设置新的分母

代码

/**
 * @description: 分数
 * @author: liangjiayy
 * @create: 2022-09-30 23:31
 **/
public class Fraction extends Number implements Comparable<Fraction>, Operationable<Fraction> {
    /**
     * 1
     */
    public static final Fraction ONE = new Fraction(1);
    /**
     * 0
     */
    public static final Fraction ZERO = new Fraction(0);
    /**
     * 分子
     */
    private long numerator;

    /**
     * 分母
     */
    private long denominator;

    public Fraction(String fractionStr) {
        String[] split = fractionStr.trim().split("/");
        if (split.length > 2 || split.length == 0) {
            throw new RuntimeException("将\"" + fractionStr + "\"转化为分数出现了异常!");
        }
        Fraction num, den;
        //分子
        if (split[0].contains(".")) {
            num = convertDouble2fraction(Double.parseDouble(split[0]));
        } else {
            num = new Fraction(Long.parseLong(split[0]));
        }
        //分母
        if (split.length == 2) {
            if (split[1].contains(".")) {
                den = convertDouble2fraction(Double.parseDouble(split[1]));
            } else {
                den = new Fraction(Long.parseLong(split[1]));
            }
        } else {
            this.numerator = num.numerator;
            this.denominator = num.denominator;
            return;
        }
        Fraction div = num.div(den);
        this.numerator = div.numerator;
        this.denominator = div.denominator;
    }

    public Fraction(double numerator) {
        Fraction fraction = convertDouble2fraction(numerator);
        this.numerator = fraction.numerator;
        this.denominator = fraction.denominator;
    }

    private Fraction convertDouble2fraction(double numerator) {
        String[] split = (numerator + "").split("\\.");
        //整数部分
        long left = Long.parseLong(split[0]);
        //小数部分
        long right = Long.parseLong(split[1]);
        int len = split[1].length();
        long pow = (long) Math.pow(10, len);
        return new Fraction(left * pow + right, pow);
    }

    public Fraction(long numerator) {
        this(numerator, 1L);
    }

    public Fraction(long numerator, long denominator) {
        this.numerator = numerator;
        this.denominator = denominator;
    }

    /**
     * Returns the value of the specified number as an {@code int},
     * which may involve rounding or truncation.
     *
     * @return the numeric value represented by this object after conversion
     * to type {@code int}.
     */
    @Override
    public int intValue() {
        return (int) (numerator / denominator);
    }

    /**
     * Returns the value of the specified number as a {@code long},
     * which may involve rounding or truncation.
     *
     * @return the numeric value represented by this object after conversion
     * to type {@code long}.
     */
    @Override
    public long longValue() {
        return numerator / denominator;
    }

    /**
     * Returns the value of the specified number as a {@code float},
     * which may involve rounding.
     *
     * @return the numeric value represented by this object after conversion
     * to type {@code float}.
     */
    @Override
    public float floatValue() {
        return (float) (1.0 * numerator / denominator);
    }

    /**
     * Returns the value of the specified number as a {@code double},
     * which may involve rounding.
     *
     * @return the numeric value represented by this object after conversion
     * to type {@code double}.
     */
    @Override
    public double doubleValue() {
        return 1.0 * numerator / denominator;
    }

    /**
     * Compares this object with the specified object for order.  Returns a
     * negative integer, zero, or a positive integer as this object is less
     * than, equal to, or greater than the specified object.
     *
     * <p>The implementor must ensure <tt>sgn(x.compareTo(y)) ==
     * -sgn(y.compareTo(x))</tt> for all <tt>x</tt> and <tt>y</tt>.  (This
     * implies that <tt>x.compareTo(y)</tt> must throw an exception iff
     * <tt>y.compareTo(x)</tt> throws an exception.)
     *
     * <p>The implementor must also ensure that the relation is transitive:
     * <tt>(x.compareTo(y)&gt;0 &amp;&amp; y.compareTo(z)&gt;0)</tt> implies
     * <tt>x.compareTo(z)&gt;0</tt>.
     *
     * <p>Finally, the implementor must ensure that <tt>x.compareTo(y)==0</tt>
     * implies that <tt>sgn(x.compareTo(z)) == sgn(y.compareTo(z))</tt>, for
     * all <tt>z</tt>.
     *
     * <p>It is strongly recommended, but <i>not</i> strictly required that
     * <tt>(x.compareTo(y)==0) == (x.equals(y))</tt>.  Generally speaking, any
     * class that implements the <tt>Comparable</tt> interface and violates
     * this condition should clearly indicate this fact.  The recommended
     * language is "Note: this class has a natural ordering that is
     * inconsistent with equals."
     *
     * <p>In the foregoing description, the notation
     * <tt>sgn(</tt><i>expression</i><tt>)</tt> designates the mathematical
     * <i>signum</i> function, which is defined to return one of <tt>-1</tt>,
     * <tt>0</tt>, or <tt>1</tt> according to whether the value of
     * <i>expression</i> is negative, zero or positive.
     *
     * @param o the object to be compared.
     * @return a negative integer, zero, or a positive integer as this object
     * is less than, equal to, or greater than the specified object.
     * @throws NullPointerException if the specified object is null
     * @throws ClassCastException   if the specified object's type prevents it
     *                              from being compared to this object.
     */
    @Override
    public int compareTo(Fraction o) {
        Fraction[] fractions = convert2sameDenominator(this, o);
        //如果分母是正数,比较分子
        if (fractions[0].denominator > 0) {
            return Long.compare(fractions[0].numerator, fractions[1].numerator);
        }

        return -Long.compare(fractions[0].numerator, fractions[1].numerator);
    }

    /**
     * 通分,将两个分数转化成同分母分数
     *
     * @param f1
     * @param f2
     * @return Fraction[0]:第一个分数转化后的结果,Fraction[1]:第二个分母转化后的结果
     */
    private Fraction[] convert2sameDenominator(Fraction f1, Fraction f2) {
        //找公倍数
        long leastCommonMultiple = findLeastCommonMultiple(f1.denominator, f2.denominator);
        Fraction[] res = new Fraction[2];
        //转化为指定的分母
        res[0] = convertDenominator(f1, leastCommonMultiple);
        res[1] = convertDenominator(f2, leastCommonMultiple);
        return res;
    }

    /**
     * 将分数的分母转化为指定的值
     * 注意:新的分母必须是旧的分母的倍数
     *
     * @param fraction
     * @param denominator 新的分母
     * @return
     */
    private Fraction convertDenominator(Fraction fraction, long denominator) {
        if (denominator % fraction.denominator != 0) {
            throw new RuntimeException("无法将\"" + fraction + "\"转化为分母为" + denominator + "的分数!");
        }
        return new Fraction(fraction.numerator * (denominator / fraction.denominator), denominator);
    }

    /**
     * 找最小公倍数
     *
     * @param num1
     * @param num2
     * @return
     */
    private long findLeastCommonMultiple(long num1, long num2) {
        //找公因数
        long greatestCommonDivisor = findGreatestCommonDivisor(num1, num2);
        //公倍数
        return num1 * num2 / greatestCommonDivisor;
    }

    /**
     * 找最大公因数
     *
     * @param num1
     * @param num2
     * @return
     */
    private long findGreatestCommonDivisor(long num1, long num2) {
        //辗转相除法
        long tmp;
        while (num2 != 0) {
            tmp = num1 % num2;
            num1 = num2;
            num2 = tmp;
        }
        return num1;
    }

    @Override
    public String toString() {
        Fraction fraction = convert2theSimplestFraction(this);
        this.numerator = fraction.numerator;
        this.denominator = fraction.denominator;

        //分母等于1,只返回分子
        if (denominator == 1) {
            return numerator + "";
        }
        if (numerator == 0) {
            return 0 + "";
        }
        return numerator + "/" + denominator;
    }

    /**
     * 加法
     *
     * @param fraction
     * @return
     */
    @Override
    public Fraction add(Fraction fraction) {
        //通分
        Fraction[] fractions = convert2sameDenominator(this, fraction);
        //分子相加
        Fraction res = new Fraction(fractions[0].numerator + fractions[1].numerator, fractions[0].denominator);
        //化简为最简带分数
        return convert2theSimplestFraction(res);
    }

    /**
     * Creates and returns a copy of this object.  The precise meaning
     * of "copy" may depend on the class of the object. The general
     * intent is that, for any object {@code x}, the expression:
     * <blockquote>
     * <pre>
     * x.clone() != x</pre></blockquote>
     * will be true, and that the expression:
     * <blockquote>
     * <pre>
     * x.clone().getClass() == x.getClass()</pre></blockquote>
     * will be {@code true}, but these are not absolute requirements.
     * While it is typically the case that:
     * <blockquote>
     * <pre>
     * x.clone().equals(x)</pre></blockquote>
     * will be {@code true}, this is not an absolute requirement.
     * <p>
     * By convention, the returned object should be obtained by calling
     * {@code super.clone}.  If a class and all of its superclasses (except
     * {@code Object}) obey this convention, it will be the case that
     * {@code x.clone().getClass() == x.getClass()}.
     * <p>
     * By convention, the object returned by this method should be independent
     * of this object (which is being cloned).  To achieve this independence,
     * it may be necessary to modify one or more fields of the object returned
     * by {@code super.clone} before returning it.  Typically, this means
     * copying any mutable objects that comprise the internal "deep structure"
     * of the object being cloned and replacing the references to these
     * objects with references to the copies.  If a class contains only
     * primitive fields or references to immutable objects, then it is usually
     * the case that no fields in the object returned by {@code super.clone}
     * need to be modified.
     * <p>
     * The method {@code clone} for class {@code Object} performs a
     * specific cloning operation. First, if the class of this object does
     * not implement the interface {@code Cloneable}, then a
     * {@code CloneNotSupportedException} is thrown. Note that all arrays
     * are considered to implement the interface {@code Cloneable} and that
     * the return type of the {@code clone} method of an array type {@code T[]}
     * is {@code T[]} where T is any reference or primitive type.
     * Otherwise, this method creates a new instance of the class of this
     * object and initializes all its fields with exactly the contents of
     * the corresponding fields of this object, as if by assignment; the
     * contents of the fields are not themselves cloned. Thus, this method
     * performs a "shallow copy" of this object, not a "deep copy" operation.
     * <p>
     * The class {@code Object} does not itself implement the interface
     * {@code Cloneable}, so calling the {@code clone} method on an object
     * whose class is {@code Object} will result in throwing an
     * exception at run time.
     *
     * @return a clone of this instance.
     * @throws CloneNotSupportedException if the object's class does not
     *                                    support the {@code Cloneable} interface. Subclasses
     *                                    that override the {@code clone} method can also
     *                                    throw this exception to indicate that an instance cannot
     *                                    be cloned.
     * @see Cloneable
     */
    @Override
    protected Fraction clone() {
        return new Fraction(this.numerator, this.denominator);
    }

    /**
     * 约分
     *
     * @param fraction
     * @return
     */
    private Fraction convert2theSimplestFraction(Fraction fraction) {
        long leastCommonMultiple = findGreatestCommonDivisor(fraction.numerator, fraction.denominator);
        if (leastCommonMultiple == 1) {
            return fraction.clone();
        }
        //分子分母,同时除以最大公约数
        return new Fraction(fraction.numerator / leastCommonMultiple, fraction.denominator / leastCommonMultiple);
    }

    /**
     * 减法
     *
     * @param fraction
     * @return
     */
    @Override
    public Fraction sub(Fraction fraction) {
        // 相反数
        fraction = getOppositeNumber(fraction);
        return add(fraction);
    }

    /**
     * 相反数
     *
     * @param fraction
     * @return
     */
    @Override
    public Fraction getOppositeNumber(Fraction fraction) {
        return new Fraction(-fraction.numerator, fraction.denominator);
    }

    /**
     * 乘法
     *
     * @param fraction
     * @return
     */
    @Override
    public Fraction mul(Fraction fraction) {
        Fraction res = new Fraction(numerator * fraction.numerator, denominator * fraction.denominator);
        return convert2theSimplestFraction(res);
    }

    /**
     * 除法
     *
     * @param fraction
     * @return
     */
    @Override
    public Fraction div(Fraction fraction) {
        fraction = getReciprocal(fraction);
        return mul(fraction);
    }

    /**
     * 倒数
     *
     * @param fraction
     * @return
     */
    @Override
    public Fraction getReciprocal(Fraction fraction) {
        return new Fraction(fraction.denominator, fraction.numerator);
    }

    public boolean isZero() {
        return this.numerator == 0;
    }

    /**
     * 分子
     *
     * @return
     */
    public long getNumerator() {
        return numerator;
    }

    /**
     * 分母
     *
     * @return
     */
    public long getDenominator() {
        return denominator;
    }

    public void setNumerator(long numerator) {
        this.numerator = numerator;
    }

    public void setDenominator(long denominator) {
        this.denominator = denominator;
    }
}

/**
 * 支持运算的,包括加、减、乘、除
 */
interface Operationable<T> {
    /**
     * 加法
     *
     * @param t
     * @return
     */
    T add(T t);

    /**
     * 减法
     *
     * @param t
     * @return
     */
    T sub(T t);

    /**
     * 乘法
     *
     * @param t
     * @return
     */
    T mul(T t);

    /**
     * 除法
     *
     * @param t
     * @return
     */
    T div(T t);

    /**
     * 相反数
     *
     * @param fraction
     * @return
     */
    Fraction getOppositeNumber(Fraction fraction);

    /**
     * 倒数
     *
     * @param fraction
     * @return
     */
    Fraction getReciprocal(Fraction fraction);
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Java实现分数 的相关文章

  • 使用 Intellij Idea 和 gradle 在应用程序引擎上调试 localhost

    我正在使用 IntelliJ 社区添加并使用 Gradle 构建应用程序引擎标准环境应用程序 在迁移到 IntelliJ 和端点框架之前 我使用的是 Android Studio 我无法调试我的本地主机 我添加了 jvmFlags 如下所述
  • 使用 Java 的 Apache Http 摘要身份验证

    我目前正在开发一个 Java 项目 但无法使 http 摘要身份验证正常工作 我尝试使用 Apache 网站 但没有帮助 我有一个需要 HTTP 摘要身份验证的网站 DefaultHttpClient httpclient new Defa
  • TreeMap 删除所有大于某个键的键

    在项目中 我需要删除键值大于某个键的所有对象 键类型为Date 如果重要的话 据我所知TreeMapJava中实现的是红黑树 它是一种二叉搜索树 所以我应该得到O n 删除子树时 但除了制作尾部视图并一一删除之外 我找不到任何方法可以做到这
  • 如何在java中将数组值排序为循环格式?

    我的数组值如下 String value 1 2 3 4 5 6 7 8 9 10 假设如果我将值 5 传递给 tat 数组 它应该按如下顺序排序 5 6 7 8 9 10 1 2 3 4 怎么办 有人帮忙吗 感谢你 你需要的就是所谓的轮换
  • 两个整数乘积的模

    我必须找到c c a b mod m a b c m 是 32 位整数 但 a b 可以超过 32 位 我正在尝试找出一种计算 c 的方法 而不使用 long 或任何 gt 32 位的数据类型 有任何想法吗 如果m是质数 事情可以简化吗 注
  • 垃圾收集器如何在幕后工作来收集死对象?

    我正在阅读有关垃圾收集的内容 众所周知 垃圾收集会收集死亡对象并回收内存 我的问题是 Collector 如何知道任何对象已死亡 它使用什么数据结构来跟踪活动对象 我正在研究这个问题 我发现GC实际上会跟踪活动对象 并标记它们 每个未标记的
  • 与 Eclipse 中的 Java Content Assist 交互

    作为我的插件项目的一部分 我正在考虑与 Eclipse 在 Java 文件上显示的内容辅助列表进行交互 我正在尝试根据一些外部数据对列表进行重新排序 我看过一些有关创建新内容辅助的教程 但没有看到有关更改现有内容辅助的教程 这可能吗 如果是
  • 如何在 Java 中向时间戳添加/减去时区偏移量?

    我正在使用 JDK 8 并且玩过ZonedDateTime and Timestamp很多 但我仍然无法解决我面临的问题 假设我得到了格式化的Timestamp在格林威治标准时间 UTC 我的服务器位于某处 假设它设置为Asia Calcu
  • 从 MATLAB 调用 Java?

    我想要Matlab程序调用java文件 最好有一个例子 需要考虑三种情况 Java 内置库 也就是说 任何描述的here http docs oracle com javase 6 docs api 这些项目可以直接调用 例如 map ja
  • 断言 Kafka 发送有效

    我正在使用 Spring Boot 编写一个应用程序 因此要写信给 Kafka 我这样做 Autowired private KafkaTemplate
  • Java 中如何将 char 转换为 int? [复制]

    这个问题在这里已经有答案了 我是Java编程新手 我有例如 char x 9 我需要得到撇号中的数字 即数字 9 本身 我尝试执行以下操作 char x 9 int y int x 但没有成功 那么我应该怎么做才能得到撇号中的数字呢 ASC
  • 如何在 Spring 中使 @PropertyResource 优先于任何其他 application.properties ?

    我正在尝试在类路径之外添加外部配置属性资源 它应该覆盖任何现有的属性 但以下方法不起作用 SpringBootApplication PropertySource d app properties public class MyClass
  • Android 无法解析日期异常

    当尝试解析发送到我的 Android 客户端的日期字符串时 我得到一个无法解析的日期 这是例外 java text ParseException 无法解析的日期 2018 09 18T00 00 00Z 位于 偏移量 19 在 java t
  • 如何仅从 Firestore 获取最新更新的数据?

    在 Firestore 上发现任何更改时始终获取整个文档 如何只获取最近更新的数据 这是我的数据 我需要在第一次加载时在聊天中按对象顺序 例如 2018 09 17 30 40 msg和sendby 并且如果数据更新则仅获取新的msg和se
  • 从jar中获取资源

    我有包含文件的 jar myJar res endingRule txt myJar wordcalculator merger Marge class 在 Marge java 中我有代码 private static final Str
  • Akka 与现有 java 项目集成的示例

    如果我已经有现有的javaWeb 应用程序使用spring and servlet容器 将 Akka 集成到其中的正确方法是什么 就像我将会有Actor1 and Actor2互相沟通的 开始使用这些演员的切入点是什么 例如 1 把它放在那
  • 使用 Elastic Beanstalk 进行 Logback

    我在使用 Elastic Beanstalk 记录应用程序日志时遇到问题 我正在 AWS Elastic Beanstalk 上的 Tomcat 8 5 with Corretto 11 running on 64bit Amazon Li
  • 轻松的反应

    我有一个与这里描述的类似的案例 动态更改RESTEasy服务返回类型 https stackoverflow com questions 3786781 dynamically change resteasy service return
  • 使用 HtmlUnit 定位弹出窗口

    我正在构建一个登录网站并抓取一些数据的程序 登录表单是一个弹出窗口 所以我需要访问这个www betexplorer com网站 在页面的右上角有一个登录链接 写着 登录 我单击该链接 然后出现登录弹出表单 我能够找到顶部的登录链接 但找不
  • Java RMI - 客户端超时

    我正在使用 Java RMI 构建分布式系统 它必须支持服务器丢失 如果我的客户端使用 RMI 连接到服务器 如果该服务器出现故障 例如电缆问题 我的客户端应该会收到异常 以便它可以连接到其他服务器 但是当服务器出现故障时 我的客户端什么也

随机推荐

  • 学生写字灯哪个牌子好?精选学生专用台灯第一品牌

    每个孩子的成长都是父母的心头大事 不管是学习上 身体上都想给予孩子最好的 甚至学习也会买台灯 光源的选择也是很重要的 学生在写字的时候用什么台灯牌子比较好呢 今天就来详细介绍一下 几款护眼的学生台灯 一 南卡护眼台灯L1 参考价 399元
  • 你想要的一眼就知道的【Symbol】

    js的基本数据类型 基本类型 String Boolean Number Symbol Undefind Null 引用类型 Array Object Function Symbol 什么是Symbol 是js语言的一种数据类型 和Stri
  • Bus error (core dumped)问题

    问题描述 项目中有多线程的操作 一个线程运行没有问题 两个线程同时运行时 出现报错 Bus error core dumped 原因分析 问题的原因 指针的中赋值与内容拷贝的问题 业务逻辑中有图像数据的拷贝过程 图像数据是unsinged
  • Mysql之视图、索引【第五篇】

    大纲 一 视图 1 什么是视图 1 MySQL 视图 View 是一种虚拟的表 是从数据库中一个或多个表中导出来的表 视图由列和行构成 行和列的数据来自于定义视图的查询中所使用的表 并且还是在使用视图时动态生成的 2 数据库中存放了视图的定
  • ipfs使用二进制文件部署私有链

    注 此版本仅适用于ipfs go ipfs v0 4 18 版本 IPFS多节点 才能构建一个本地的分布式文件系统 在联盟链开发环境下 多数会使用到IPFS多节点私有网存储文件 一 IPFS二进制安装 1 1 下载ipfs二进制文件 wge
  • Python接口自动化测试之详解post请求

    前言 在HTTP协议中 与get请求把请求参数直接放在url中不同 post请求的请求数据需通过消息主体 request body 中传递 且协议中并没有规定post请求的请求数据必须使用什么样的编码方式 所以其请求数据可以有不同的编码方式
  • wpscloudsvr.exe 怎么删除

    WPS Office安装之后 一直很卡 主要是wpscloudsvr exe这个登录账号的进程太卡了 把它禁止了就行了 1 打开 任务管理器 gt 服务 gt 找到 wpscloudsvr 右键 停止 2 先打开wps 任务管理器 gt 进
  • python 使用 pymssql 调用存储过程并让他返回值

    众所周知 pymssql 库并不支持 暂时 调用存储过程 只能使用原生的sql 语句让其调用 这样一来如果需要让pymssql调用存储过程并让其返回值 显然return语句是不能用了 但是我们可以使用 select 语句让其返回值 比如 我
  • Redis之key和value可以存储的最大值

    文章目录 Redis之key和value可以存储的最大值 1 Redis的key可以存储的最大值 2 Redis的value可以存储的最大值 Redis之key和value可以存储的最大值 1 Redis的key可以存储的最大值 虽然Key
  • ue4文档学习进度

    由于Ue4文档很多 有时又间隔一段时间再看 忘了在哪里了 所以先记录下 截至2022年1月18日 触发器Actor https docs unrealengine com 4 26 zh CN Basics Actors Triggers
  • STM32野火指南者中断EXTI按键点灯

    一 野火官方中断框图 1 输入线 外部中断选择 如 EXTI0 EXTI19 2 配置中断所需寄存器 如 GPIO EXTI NVIC 3 按键1按键2 采用上升沿 下降沿触发 自己设定 二 编程顺序 1 初始化GPIO 即连接到EXTI的
  • [Android学习] 1. 简易登录界面设计

    通过对活动及控件的学习 今天制作一个简易登录界面 简要记录一下操作过程 遇到的问题及学到的经验 希望各位老师多多提出问题不吝赐教 预期设计效果图 设计要求 1 布局不限 参考上图 2 利用EditText制作输入框 有语言提示 3 登录注册
  • 浅谈企业微信公域到私域流量玩法

    一 搭建私域流量池 高效引流客户 客户通过渠道活码添加员工 自动打标签 实时统计引流情况 发送个性化的欢迎语 第一时间送上问候 二 将企业公域流量引流裂变为私域 生成引流裂变海报 通过老用户奖励式分享拉新 实现用户指数级增长 加强用户联系
  • AMD GPU安装运行stable diffusion

    本文操作环境为Windows10 11 AMD AI绘画是一种利用人工智能技术进行绘画的方法 它可以通过机器学习算法来学习艺术家的风格 并生成类似于艺术家的作品 最近 AI绘画技术得到了很大的发展 许多公司和研究机构都在进行相关的研究和开发
  • [C-SAE] SPAT解析消息及说明

    1 消息内容
  • PyTorch 训练一个分类器

    文章目录 0 前言 1 加载和规范化CIFAR10 2 定义一个卷积网络 3 定义损失函数和优化器 4 训练网络 5 测试网络 6 在GPU上训练模型 参考资料 0 前言 TRAINGING A CLASSIFIER 这篇教程很清楚的描述了
  • Visual Studio 2017 许可证已过期解决方案

    参考文章 https blog csdn net qq 19678579 article details 76692822
  • 防缓存穿透利器-隆过滤器(BloomFilter)

    防缓存穿透利器 布隆滤器 BloomFilter 一 布隆过滤器原理 如果想要判断一个元素是不是在一个集合中存在 一般的想法是将所有元素保存起来 然后再拿着这个元素在集合中一个一个进行比对 但是随着集合中元素的增加 我们需要的存储空间越来越
  • java实现九九乘法表

    以下仅是我自己的想法 小伙伴们有其他一些好的想法希望多多交流 以上是九九乘法表的运行图 从上图可以分析出 应该使用二重循环 由我之前的文章可知 二重循环外层控制行数 内层控制列数 所以一共有九行九列的二重循环 根据上图 可以很快写出如下代码
  • Java实现分数

    自己独立实现的 如果有bug或者错误 欢迎评论区留言 文章目录 文档 代码 文档 字段摘要 修饰符 字段 解释 static final Fraction ONE 分数 1 分子 分母都是1的分数 static final Fraction