- import java.util.Scanner;
- public class C1
- {
- public static void main(String[] args)
- {
- Scanner input = new Scanner(System.in);
- //提示使用者輸入
- System.out.println("請輸入人數:");
- double number = input.nextDouble();
- System.out.println("請輸入分數:");
- double score = input.nextDouble();
- double count = 1;
- //剛開始輸入的分數同時是最大也會是第二大
- double first = score ;
- double second = score;
- //輸入並計算結果
- while(count < number)
- {
- System.out.println("請輸入分數:");
- score = input.nextDouble();
- count = count + 1;
- if (score > first && count == 2 )
- {
- first = score;
- }
- else if (score < first && count == 2 )
- {
- second = score;
- }
- else if(score >= first && count > 2 )
- {
- first = score;
- }
- else if(score >= second && score <= first && count > 2)
- {
- second = score;
- }
- }
- //輸出結果
- System.out.println("最高分:" + first);
- System.out.println("第二高分:" + second);
- }
- }
2014年12月24日 星期三
java程式設計題目---數字處理【找出第一第二高分】
設計一程式,提示使用者輸入n個分數(0~100),計算並顯示它們的最高分、第二高分於螢幕。
訂閱:
張貼留言 (Atom)
Go(Golang)程式語言 設定GCC
下載MSYS2: https://www.msys2.org/ 安裝 程式開始執行後輸入: pacman -Syu y y 在安裝目錄底下找到msys2.exe,雙擊執行 輸入指令: pacman -Su pacman -S --needed base-devel mingw-...
-
MNIST手寫數字辨識資料集 MNIST手寫數字辨識資料集 ,是由 Yann LeCun(揚·勒丘恩) 大神所蒐集,這位大神同時也是Convulution Nueral Networks(卷積神經網絡)的創始人,因此享有"卷積網絡之父"的美譽。關於這位大...
-
Write a program that reads an integer between 100 and 999, and show the result of the sum, product and difference of all its digits. For ex...
-
設計一程式,提示使用者輸入正整數n,判斷此數是否為質數並將結果印出。
沒有留言:
張貼留言