数据的运算,求和,两数求最大,三数求最大,两数是否相等

 1 package debug;
 2 
 3 import java.util.Scanner;
 4 public class Demo3 {
 5     
 6     public static void main(String[] args) {
 7         
 8         Scanner sc = new Scanner(System.in);
 9         System.out.println("请输入第一个值:");
10         int x = sc.nextInt();
11         System.out.println("请输入第二个值:");
12         int y = sc.nextInt();
13         System.out.println("请输入第三个值:");
14         int z = sc.nextInt();
15         
16         boolean flag = (x == y);
17         int sum = x + y + z;
18         int max1 = (x > y)? x:y;
19         int max2 = (max1 > z)? max1:z;
20         
21         System.out.println("前两个数是否相等:" + flag);
22         System.out.println("三个数的和为:" + sum);
23         System.out.println("前两者中的最大值为:" + max1);
24         System.out.println("三个数中的最大值为:" + max2);
25     }
26 
27 }

 

posted @ 2018-11-21 15:10  iSZ  阅读(264)  评论(0编辑  收藏  举报