S2B 03 林安妮 Annie
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # **善良的小明** **Content** --- 善良的小明是個心靈脆弱的高中生,他設計了一個程式來安慰考試不如預期的自己和同學。 輸入多位學生的成績,計算每位學生的總分、平均、等第與排名,並印出成績表和鼓勵語。 **輸入格式** --- 1. 第一行輸入一個整數n,代表學生人數(不超過100)。 2. 接下來n行,每行輸入5個整數,代表該學生的國文、英文、數學、自然、社會成績。 **輸入格式範例** --- | 輸入學生人數 | 1 | | --------------------- | --- | 輸入第一位學生的分數 | 國文 | 86 | | ---- | --- | | 英文 | 92 | | 數學 | 57 | | 自然 | 81 | | 社會 | 65 **輸出格式範例** --- 英文 數學 自然 社會 總分 平均 等第 排名 1 86 92 57 81 65 381 76.2 乙 3 給第 1 號同學的鼓勵語:有穩定的表現,再多努力一點會更好! **程式內容+註解** ```c++= #include <iostream> // 引入輸入輸出功能 using namespace std; int main() { const int sub = 5; // 固定有 5 科:數學、國文、英文、自然、社會 int st; // 儲存學生人數 float sum; // 暫存每位學生的總分 // ▶ 使用者輸入學生人數 cout << "輸入學生人數: "; cin >> st; // ▶ 宣告 2D 陣列來存每位學生的分數資料 // 每位學生有 sub 科成績 + 總分 + 平均 + 排名 = sub + 3 欄 float score[st][sub + 3]; // ▶ 建立科目名稱陣列,照指定順序:國文→英文→數學→自然→社會 string subjects[sub] = {"國文", "英文", "數學", "自然", "社會"}; // ▶ 依序輸入每位學生的各科分數 for (int i = 0; i < st; i++) { cout << "輸入第 " << i + 1 << " 位學生的分數:" << endl; for (int j = 0; j < sub; j++) { // 顯示提示,要求輸入各科成績 cout << subjects[j] << ": "; cin >> score[i][j]; // 儲存輸入成績到對應位置 } } // ▶ 計算每位學生的總分與平均 for (int i = 0; i < st; i++) { sum = 0; // 每次計算前先將總和歸零 for (int j = 0; j < sub; j++) { sum += score[i][j]; // 將所有科目成績加總 } score[i][sub] = sum; // 將總分存到第 sub 欄 score[i][sub + 1] = sum / sub; // 將平均存到第 sub+1 欄 } // ▶ 計算學生排名:成績高者排名靠前 for (int i = 0; i < st; i++) { int rank = 1; // 預設每位學生初始排名為 1(最高) for (int j = 0; j < st; j++) { // 比較平均分,若有其他學生平均更高,則排名後移 if (score[j][sub + 1] > score[i][sub + 1]) { rank++; } } score[i][sub + 2] = rank; // 將排名存到第 sub+2 欄 } // ▶ 輸出成績標題列 cout << "\n座號\t"; for (int i = 0; i < sub; i++) { cout << subjects[i] << "\t"; // 輸出科目名稱 } cout << "總分\t平均\t等第\t排名" << endl; // ▶ 輸出每位學生的所有資料(成績、總分、平均、等第、排名) for (int i = 0; i < st; i++) { cout << i + 1 << "\t"; // 座號從 1 開始 // 輸出各科成績、總分與平均(sub + 2 個欄位) for (int j = 0; j < sub + 2; j++) { cout << score[i][j] << "\t"; } // ▶ 判斷等第(根據平均分數) for (int i = 0; i < st; i++) { sum = 0; // 每次計算前先將總和歸零 for (int j = 0; j < sub; j++) { sum += score[i][j]; // 將所有科目成績加總 } score[i][sub] = sum; // 將總分存到第 sub 欄 score[i][sub + 1] = sum / sub; // 將平均存到第 sub+1 欄 } // ▶ 計算學生排名:成績高者排名靠前 for (int i = 0; i < st; i++) { int rank = 1; // 預設每位學生初始排名為 1(最高) for (int j = 0; j < st; j++) { // 比較平均分,若有其他學生平均更高,則排名後移 if (score[j][sub + 1] > score[i][sub + 1]) { rank++; } } score[i][sub + 2] = rank; // 將排名存到第 sub+2 欄 } // ▶ 輸出成績標題列 cout << "\n座號\t"; for (int i = 0; i < sub; i++) { cout << subjects[i] << "\t"; // 輸出科目名稱 } cout << "總分\t平均\t等第\t排名" << endl; // ▶ 輸出每位學生的所有資料(成績、總分、平均、等第、排名) for (int i = 0; i < st; i++) { cout << i + 1 << "\t"; // 座號從 1 開始 // 輸出各科成績、總分與平均(sub + 2 個欄位) for (int j = 0; j < sub + 2; j++) { cout << score[i][j] << "\t"; } // ▶ 判斷等第(根據平均分數) float avg = score[i][sub + 1]; if (avg >= 90) cout << "優"; else if (avg >= 80) cout << "甲"; else if (avg >= 70) cout << "乙"; else if (avg >= 60) cout << "丙"; else cout << "丁"; // ▶ 輸出排名 cout << "\t" << (int)score[i][sub + 2] << endl; } // ▶ 給每位學生鼓勵語(依平均成績分類) cout << endl; for (int i = 0; i < st; i++) { float avg = score[i][sub + 1]; // 取得平均分數 cout << "給第 " << i + 1 << " 號同學的鼓勵語:"; // 根據平均給出不同的鼓勵文字 if (avg >= 90) cout << "表現非常優秀,繼續保持喔!" << endl; else if (avg >= 80) cout << "不錯喔!你已經很接近優等了,加油!" << endl; else if (avg >= 70) cout << "有穩定的表現,再多努力一點會更好!" << endl; else if (avg >= 60) cout << "不要氣餒,穩扎穩打,一定能進步!" << endl; else cout << "每個人都有自己的節奏,別放棄,加油!" << endl; } return 0; // 程式結束 } } ``` **執行結果** --- [https://onlinegdb.com/0yirwCfgi] **心得** --- **03 林安妮** 這次作業從開始著手,到最後的交出報告,確實可以說是『歷經千辛萬苦』。先是拼盡全力無法戰勝HackMD中沒辦法對齊的程式,我對不起Ms.吳在「溝通與表達」課程對我的教導,深感慚愧。接著是製作報告時我的電腦悲慘的當機+死機好幾次,最後才成功交出報告,是高中生涯中令我記憶數一數二深刻的一次作業。很有趣的一次設計程式經驗,不希望會有下一次。抱歉了Shola老師,請相信我是真心喜歡您的課。 **04施妤蓁** 學會不只是寫程式,還要反覆測試、比對輸出才能保證程式正確。 **11黃苡晴** 輸入數字等動作繁瑣,要確保真的都有打對,才不會前功盡棄。希望小明藉由這個系統提升自己的成績。 **12 楊喻軫** 這次的作業讓我學到原來要真的會寫程式不是一天兩天能做的事情,這作業讓我更了解程式的運作也讓我發現原來幾個字母跟數字可以做出那麼豐富的東西。 **分工** --- **03 林安妮** 程式設計與改編 報告 **04施妤蓁** 報告 **11黃苡晴** 報告 **12 楊喻軫** 報告

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully