0
点赞
收藏
分享

微信扫一扫

Codeforces Round #173 (Div. 2) / 282A Bit++(模拟)




A. Bit++



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



time limit per test



memory limit per test



input



output



The classic programming language of Bitland is Bit++. This language is so peculiar and complicated.

x. Also, there are two operations:

  • ++ increases the value of variable x
  • -- decreases the value of variable x

x. The statement is written without spaces, that is, it can only contain characters "+", "-", "X". Executing a statement means applying the operation it contains.

A programme in Bit++ is a sequence of statements, each of them needs to be executed. Executing a programme means executing all the statements it contains.

x is 0. Execute the programme and find its final value (the value of the variable when this programme is executed).



Input



n (1 ≤ n ≤ 150)

n lines contain a statement each. Each statement contains exactly one operation (++ or --) and exactly one variable x (denoted as letter «X»). Thus, there are no empty statements. The operation and the variable can be written in any order.



Output



x.



Sample test(s)



input



1 ++X



output



1



input



2 X++ --X



output



0





water.






完整代码:


/*30ms,0KB*/

#include<cstdio>

int main()
{
	int n, x = 0;
	char str[4];
	scanf("%d", &n);
	while (n--)
	{
		scanf("%s", str);
		if (str[1] == '+')
			++x;
		else
			--x;
	}
	printf("%d", x);
	return 0;
}



举报

相关推荐

0 条评论