#44015: 有點難度


yp11351280@yphs.tp.edu.tw (710-43)

學校 : 臺北市私立延平高級中學
編號 : 276272
來源 : [1.164.243.217]
最後登入時間 :
2025-04-07 23:06:23
d018. 字串讀取練習 | From: [203.72.178.1] | 發表日期 : 2024-11-05 17:22

#include <iostream>
#include <sstream>
#include <string>
using namespace std;
int main() {
    int n; char colon; double d, ans = 0.0;
    string line;
    while(getline(cin,line)) {
        istringstream in(line);
        while(in>>n>>colon>>d) {
            if(n%2==0) ans = ans-d;
            else ans = ans +d;
        }
        cout<<ans<<endl;
        ans=0.0;
    }
}
 
 
 
ZeroJudge Forum