2차 방정식의 풀이

sanholee63 Reply 7 years 8 weeks ago
import java.util.Scanner; public class Main{ public static void main(String[] args){ Scanner keyboard=new Scanner(System.in); double a=keyboard.nextDouble(); double b=keyboard.nextDouble(); double c=keyboard.nextDouble(); while(a>100||a<-100){ a=keyboard.nextDouble(); } while(b>100||b<-100){ b=keyboard.nextDouble(); } while(c>100||c<-100){ c=keyboard.nextDouble(); } double d=Math.pow(b, 2)-4*a*c; double e=Math.sqrt(d); double r1=(-b+e)/2; double r2=(-b-e)/2; double r3=-b/2; if(d>=0){ if(r1>r2){ r1= (Math.floor(r1*10)/10); System.out.printf("%.1f",r1); } else{ r2= (Math.floor(r2*10)/10); System.out.printf("%.1f",r2); } } else if(d<0){ System.out.println("complex"); } } } 이클립스에서는 -0.4 나오는에 WA 뜨네요 뭐가 잘못이죠?
withcs1 Reply 7 years 8 weeks ago
29 30 라인 식이틀렸어요 질문내용에 코드 복붙하지마세요~