Skip to content

Instantly share code, notes, and snippets.

@pinglunliao
Last active November 5, 2019 08:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pinglunliao/7f72ab04600b01f9a5b8 to your computer and use it in GitHub Desktop.
Save pinglunliao/7f72ab04600b01f9a5b8 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <sstream>
using namespace std;
int main()
{
string str;
while(getline(cin, str))
{
int serial;
char dummy;
double real;
double result = 0;
istringstream buffer(str);
while(buffer >> serial >> dummy >> real)
{
//cout << serial << dummy << real << " ";
if( serial & 1 )
result += real;
else
result -= real;
//cout << result << endl;
}
cout << result << endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment