当前位置:网站首页>1101 How many times B is A (15 points)

1101 How many times B is A (15 points)

2022-08-11 07:47:00 dumb bit

题目要求:
在这里插入图片描述
代码:

import java.util.Scanner;

public class Main {
    
    public static void main(String[] args) {
    
        Scanner scan = new Scanner(System.in);
        int num = scan.nextInt();
        int n = scan.nextInt();
        //准备
        String str = num + "";
        int length = str.length();
        
        //拼接
        String right = str.substring(length - n);
        String left = str.substring(0,length-n);
        str = right + left;
        double result = (double)Integer.valueOf(str) / num;

        //倍数
        System.out.print(String.format("%.2f",result));
    }
}

结果:
在这里插入图片描述

原网站

版权声明
本文为[dumb bit]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/223/202208110645413371.html