#33161: 答案不用錢


yp11151138@yphs.tp.edu.tw (801-34許劭頎)

學校 : 臺北市私立延平高級中學
編號 : 197089
來源 : [203.72.178.1]
最後登入時間 :
2024-01-16 09:50:01
d018. 字串讀取練習 | From: [203.72.178.1] | 發表日期 : 2022-12-07 17:15

#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;char colon;float f,ans=0.0;
    string line;
    while(getline(cin,line)){
        istringstream s(line);
        while(s>>n>>colon>>f)
        if(n%2==0) ans=ans-f;
        else ans=ans+f;
        cout<<ans<<endl;
        ans=0.0;
    }
    return 0;
}

 
ZeroJudge Forum