#46269: 久違放晴的天空


1121226@stu.wghs.tp.edu.tw (Arthur✨EC)

學校 : 臺北市私立薇閣高級中學
編號 : 252772
來源 : [60.248.154.139]
最後登入時間 :
2025-08-21 12:59:45

#include <bits/stdc++.h>
using namespace std;
int main(){
    string line;
    vector<int> firstRow;
    // 讀取第一行
    getline(cin, line);
    // 使用正式的 for 循環解析數字
    string currentNum="";
    for(int i=0;i<line.length();i++){
        char c=line[i];
        if(c==' '){
            if(!currentNum.empty()){
                firstRow.push_back(stoi(currentNum));
                currentNum="";
            }
        }
        else {
            currentNum+=c;
        }
    }
    // 處理最後一個數字(如果有)
    if(!currentNum.empty()){
        firstRow.push_back(stoi(currentNum));
    }
    // 找出中間位置
    int n=firstRow.size();
    int middleIndex;
    if(n%2==1){
        // 奇數個人,取正中間
        middleIndex=n/2;
    }
    else {
        // 偶數個人,取中間偏右
        middleIndex=n/2;
    }
    cout<<firstRow[middleIndex]<<endl;
    return 0;
}