【算法】长字符串相除

【墨奇科技】

给定两个以字符串形式表示的非负整数num 1和num 2, 返回num 1除以num 2的整数商quotient和余数remainder。
两个输入num 1和num 2均为字符串格式, 长度不超过100个字符, 只由数字0~9构成, 除非表示数字0, 否则均不会以字符’0’开头, 其中num 2不会为’0’, 两个输出quotient和remainder也都为字符串格式。
例如:输入num 1=“11”和num 2=“4”。应输出"2, 3”。

package com.dove;
/**
 * <p>The following is a class description.</p>
 *
 * @author Guo S.Y.
 * @version V1.0
 * @since 2022/7/31
 */
public class Demo{
   

    public boolean Compare(String first, String second) {
   
        int len1 = first.length();
        int len2 = second.length();
        if (len1 < len2) {
   
            return false;
        } else {
   
            return len1 != len2 || first.charAt(0) >= second.charAt(0);
        }
    }

    public String sub(String num1, String num2) {
   
        boolean fushu = false;
        if (num1.length() < num2.length()) {
   
            String temp = num1;
            num1 = num2;
            num2 = temp;
            fushu = true;
        } else if (num1.length() == num2.length()
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值