diff --git a/b.java b/b.java new file mode 100644 index 0000000..fc43d09 --- /dev/null +++ b/b.java @@ -0,0 +1,20 @@ +//package log; +import java.util.Scanner; +public class b { + public static void main(String[] args) { + int a; + int x; + double result; + System.out.println("输入底数a(a>0且a!=1):"); + Scanner sc = new Scanner(System.in); + a=sc.nextInt(); + System.out.println("输入真数x:"); + x=sc.nextInt(); + result = log(x, a); + System.out.println(result); + } + + private static double log(double value, double base) { + return Math.log10(value) / Math.log10(base); + } +}