输入两个实数,按照从小到大的顺序输出这两个数
import java.util.Scanner;
public class b{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
double a,b;
a=sc.nextDouble();b=sc.nextDouble();
if(a>b)
System.out.println(a+","+b);
else
System.out.println(b+","+a);
}
}
键盘输入三个实数作为三角形的三边长,判断能否构成合法的三角形
import java.util.Scanner;
public class b {
public static void main(String[] srgs){
Scanner sc=new Scanner(System.in);
double a,b,c;
a=sc.nextDouble();b=sc.nextDouble();c=sc.nextDouble();
if(a+b>c&&a+c>b&&b+c>a&&a-b<c&&a-c<b&&b-c<a)
System.out.println("yes");
else
System.out.println("no");
}
}
已知一个三角形的三条边长为a,b,c,则其面积公式为:
![](https://img-blog.csdn.net/20150320184129327?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvcXFfMjQ5Mjg0NTE=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center)
其中t= (a+b+c)/2。
import java.util.Scanner;
public class cc {
public static void mian(String[] srgs){
Scanner dn=new Scanner(System.in);
double a,b,c,t;
a=dn.nextDouble();
b=dn.nextDouble();
c=dn.nextDouble();
t=(a+b+c)/2;
System.out.println(Math.sqrt(t*(t-a)*(t-b)*(t-c)));
}
}
public class rr {
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
double a,b,c,d,e;
a=sc.nextDouble();b=sc.nextDouble();
c=sc.nextDouble();d=sc.nextDouble();e=sc.nextDouble();
System.out.println(Math.sqrt(a*b-c*d/e));
}
}
import java.util.Scanner;
public class b{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
double a,b;
a=sc.nextDouble();b=sc.nextDouble();
if(a>b)
System.out.println(a+","+b);
else
System.out.println(b+","+a);
}
}
键盘输入三个实数作为三角形的三边长,判断能否构成合法的三角形
import java.util.Scanner;
public class b {
public static void main(String[] srgs){
Scanner sc=new Scanner(System.in);
double a,b,c;
a=sc.nextDouble();b=sc.nextDouble();c=sc.nextDouble();
if(a+b>c&&a+c>b&&b+c>a&&a-b<c&&a-c<b&&b-c<a)
System.out.println("yes");
else
System.out.println("no");
}
}
已知一个三角形的三条边长为a,b,c,则其面积公式为:
其中t= (a+b+c)/2。
import java.util.Scanner;
public class cc {
public static void mian(String[] srgs){
Scanner dn=new Scanner(System.in);
double a,b,c,t;
a=dn.nextDouble();
b=dn.nextDouble();
c=dn.nextDouble();
t=(a+b+c)/2;
System.out.println(Math.sqrt(t*(t-a)*(t-b)*(t-c)));
}
}
定义5个实型变量,分别赋值为2,3,4,3.1,6.2,计算如下算式的值
public class rr {
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
double a,b,c,d,e;
a=sc.nextDouble();b=sc.nextDouble();
c=sc.nextDouble();d=sc.nextDouble();e=sc.nextDouble();
System.out.println(Math.sqrt(a*b-c*d/e));
}
}