-
Notifications
You must be signed in to change notification settings - Fork 0
/
1_1.cpp
33 lines (31 loc) · 920 Bytes
/
1_1.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);cin.tie(NULL);
std::ifstream file("inputs/input1_1.txt");
std::string lineInputInCharacters;
char typeOfFrequencyChange;
long long frequncySum = 0, lineInputInInteger = 0;
while(std::getline(file, lineInputInCharacters))
{
lineInputInInteger = 0;
for (int i = 1; lineInputInCharacters[i] != '\0'; ++i)
{
lineInputInInteger = (lineInputInInteger * 10) + (lineInputInCharacters[i] - 48 );
}
//cout<<lineInputInInteger<<"\n";
typeOfFrequencyChange = lineInputInCharacters[0];
//cout<<typeOfFrequencyChange<<"\n";
if(typeOfFrequencyChange == '+')
{
frequncySum = frequncySum + lineInputInInteger;
}
else if(typeOfFrequencyChange == '-')
{
frequncySum = frequncySum - lineInputInInteger;
}
}
cout<<frequncySum;
return 0;
}