编写一个程序,从键盘输入三个整数,求三个整数中的最小值。

关键:声明变量temp   与各数值比较。

 1 package Exam01;
 2 import java.util.Scanner;
 3 
 4     public class Topic03 {
 5     public static void main(String[] args) {
 6     // TODO Auto-generated method stubint a,b,c;
 7     //输入
 8     Scanner input = new Scanner(System.in);
 9     System.out.println("请输入一个整数:");
10     a = input.nextInt();
11     System.out.println("请输入二个整数:");
12     b = input.nextInt();
13     System.out.println("请输入三个整数:");
14     c = input.nextInt();
15     System.out.println(a+","+b+","+c);
16     int temp;int min;
17     if(a>b){
18         temp = a;
19         a = b;
20         b = temp;
21     }
22     if(a>c){
23         min = b;
24     }else{
25         min = a;
26     }if(min>c){
27         min = c;
28     }
29         System.out.println("最小值:" + min);
30     }
31 }                

 

相关文章:

  • 2022-12-23
  • 2021-05-11
  • 2021-07-14
  • 2022-12-23
  • 2021-04-02
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-19
  • 2021-05-03
  • 2021-11-19
相关资源
相似解决方案