#18186: 求救: WA (line:4)


089487 (089487)

學校 : 國立臺灣師範大學附屬高級中學
編號 : 82069
來源 : [140.112.150.137]
最後登入時間 :
2024-10-03 16:28:37
d018. 字串讀取練習 | From: [1.171.172.155] | 發表日期 : 2019-06-25 14:40

#include<bits/stdc++.h>
using namespace std;
int main()
{
string s;
int line=0;
while(getline(cin,s))
{
stringstream ss(s);
string a,c;
int x;
double y;
//vector<int> v2;
double n=0;
while(ss>>a)
{


//cout<<a<<" ";
int i=0;
while(a[i]!=':') c+=a[i],i++;
//cout<<c<<endl;
stringstream s2(c);
s2>>x;
//cout<<x<<" ";
c.clear();
for(;i<a.length();i++) c+=a[i];
s2.clear();
s2<<c;
s2>>y;
if(x%2==1) n+=y;
else n-=y;
// cout<<n<<" "<<m<<endl;
c.clear();
s2.clear();
}
cout<<n<<endl;
}
}

 
ZeroJudge Forum