Codeforces Round #173 (Div. 2) A. Bit++

http://codeforces.com/problemset/problem/282/A

题意:
Bit++只有4种运算
X++,++X表示+1,X–,–X表示-1
求最后的结果。

PS:所以只要判断中间是加还是减即可。

代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <bits/stdc++.h>
using namespace std;

int main() {
int n, x = 0;
cin >> n;
while (n--) {
char a, b, c;
cin >> a >> b >> c;
if (b == '+') x++;
if (b == '-') x--;
}
printf("%d\n", x);
return 0;
};