a244. 新手訓練 ~ for + if 5/16/2025

解法一、switch case

✅ 完整代碼

評分結果(參考) : AC (9ms, 328KB)

#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n, a, b, c;
    cin >> n;

    for(int i=0; i<n; i++){
        cin >> a >> b >> c;
        switch(a){
            case 1: cout << b+c << "\n"; break;
            case 2: cout << b-c << "\n"; break;
            case 3: cout << b*c << "\n"; break;
            case 4: cout << b/c << "\n"; break;
        }
    }

    return 0;
}