为什么样例可以过,结果:
RE #1 Runtime Error. Program exited with code 1. 0ms/0B
RE #2 Runtime Error. Program exited with code 1. 83ms/27.62MB
AC #3 Accepted, 得分 20.ok accepted 83ms/27.45MB
WA #4 Wrong Answer.wrong answer On line 1 column 1, read 0, expected 8. 0ms/0B
RE #5 Runtime Error. Program exited with code 1.
有没有哪位学JAVA的帮我看一下,我才刚学没多久
import java.util.Scanner;
public class Main {
public static void main(String[] args){
Scanner s = new Scanner(System.in);
int a,b,c;
a = s.nextInt();
b = s.nextInt();
c = s.nextInt();
float i = P(a,b,c);
float x = (float) S(i,a,b,c);
String str = String.format("%.1f",x);
System.out.println(str);
}
static int P(int a,int b,int c){
return ((a + b + c)) / 2;
}
static double S(float i, int a, int b, int c){
float sjx = i * (i - a) * (i - b) * (i - c);
return sqrt(sjx);
}
public static double sqrt(double c){
if(c < 0) return Double.NaN;
double err = 1e-7;
double x = c;
while(Math.abs(x - c/x) > err){
x = (x + c/x) / 2.0;
}
return x;
}
}