fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. // your code goes here
  13. }
  14. }
Success #stdin #stdout 0.07s 54656KB
stdin
#include <iostream>
using namespace std;

int main() {
    // 宣告陣列,25人分數(可以自己修改分數內容)
    int scores[25] = {
        85, 90, 78, 92, 88,
        76, 95, 89, 84, 91,
        77, 83, 86, 94, 80,
        79, 87, 93, 82, 75,
        81, 96, 74, 73, 97
    };

    int number;

    cout << "請輸入學生的號碼(1~25):";
    cin >> number;

    // 檢查輸入是否合法
    if (number < 1 || number > 25) {
        cout << "錯誤:號碼必須在 1 到 25 之間!" << endl;
    } else {
        cout << "第 " << number << " 號學生的分數為:" << scores[number - 1] << " 分" << endl;
    }

    return 0;
}
stdout
Standard output is empty