You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
p6hsylpbf/b.java

21 lines
527 B

4 years ago
//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);
}
}