Advertisement
realever15

俊豪作業簡單02

Mar 11th, 2015
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.44 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class zxc {
  3.  
  4.  
  5.     public static void main(String[] args)
  6.     {
  7.         Scanner scn = new Scanner(System.in);
  8.         int[] num = new int[5];
  9.         int temp=0;
  10.         System.out.print("請輸入5個整數:");
  11.         for(int i=0;i<5;i++)
  12.         {  
  13.             num[i] = scn.nextInt();
  14.             if(num[i]>temp)
  15.                 temp = num[i];
  16.         }
  17.        
  18.         System.out.printf("最大的數字為%d\n",temp);
  19.     }
  20.  
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement