CF 282A bit++
来源:互联网 发布:编辑gif软件 编辑:程序博客网 时间:2024/06/06 05:12
极其水的一道语法题;
就是输入然后判断增加减少;
The classic programming language of Bitland is Bit++. This language is so peculiar and complicated.
The language is that peculiar as it has exactly one variable, called x. Also, there are two operations:
- Operation ++ increases the value of variablex by 1.
- Operation -- decreases the value of variablex by 1.
A statement in language Bit++ is a sequence, consisting of exactly one operation and one variablex. 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.
You're given a programme in language Bit++. The initial value of x is 0. Execute the programme and find its final value (the value of the variable when this programme is executed).
The first line contains a single integer n(1 ≤ n ≤ 150) — the number of statements in the programme.
Next n lines contain a statement each. Each statement contains exactly one operation (++ or--) and exactly one variablex (denoted as letter «X»). Thus, there are no empty statements. The operation and the variable can be written in any order.
Print a single integer — the final value of x.
1++X
1
2X++--X
0
AC代码:
#include <bits/stdc++.h>using namespace std ;int main(){char a[4];int x = 0 ;int n ;cin>>n; while(n--){cin>>a;if(a[0]=='+'||a[1]=='+'){x++;}else if(a[0]=='-'||a[1]=='-'){x--;} } cout<<x<<endl; return 0 ;}
- CF 282A bit++
- coderforce 282A Bit++
- CodeForces-282A-Bit++
- 282A - Bit++
- 282A - Bit++
- codeforces 282A Bit++
- Problem--282A--Codeforces--BIt++
- A. Bit++
- A.Bit++
- CF 282 A 282B 282C
- CodeForces - 282A Bit++ (水)
- 【CodeForces 282A】Bit++(水~)
- CodeForces 282 A.Bit++(水~)
- cf 600人 bit+大量stl乱搞
- CF 2A Winner
- CF 128A Statues
- <cf>A. Exams
- CF 109A
- 要求:以发工资为例构建一个观察者模式
- AVL树的c++实现
- Genymotion-ARM-Translation_v1.1.zip无法拖入虚拟机的解决方案
- JVM学习笔记-运行时数据区域
- 从采集数据到领导查看过程,你还要浪费多少人力?
- CF 282A bit++
- HDOJ 2504
- 1040. Longest Symmetric String (25)
- 多态的应用 虚函数
- 算法代码实现之选择排序,C/C++ 实现
- RPM打包记录
- 《leetCode》: Pascal's Triangle II
- Core Animation 编程指南
- JavaScript面向对象之---工厂模式