1.例13.1二次函数的解
import java.util.Scanner; public class Cjava { public static void main(String[]args) { float a,b,c,disc; System.out.println("input a,b,c:"); Scanner s=new Scanner(System.in); a=s.nextFloat(); b=s.nextFloat(); c=s.nextFloat(); if(a==0) { System.out.println("a is equal to zero,error!"); } else if((disc=b*b-4*a*c)<0) { System.out.println("disc<0"); } else { System.out.println("x1="+((-b+Math.sqrt(disc))/(2*a))); System.out.println("x2="+((-b- Math.sqrt(disc))/(2*a))); } } }
2.没问题
3.明天继续写例题