题目

1428: Bit++

Time Limit: 1 Sec Memory Limit: 128 MB
Submit: 187 Solved: 144
[Submit][Status][Web Board]
Description

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 variable x by 1.
·Operation – decreases the value of variable x by 1.
A statement in language Bit++ is a sequence, consisting of exactly one operation and one variable 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.
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).

Input

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 variable x (denoted as letter «X»). Thus, there are no empty statements. The operation and the variable can be written in any order.

Output

Print a single integer — the final value of x.

Sample Input

1
++X
2
X++
--X

Sample Output

1
0

想法

题目意思如果没读懂可能觉得有点难办,其实就是从0到n-1,然后根据指令判断+1还是-1


AC代码

#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define pre(i,a,b) for(int i=a;i>=b;--i)
#define m(x) memset(x,0,sizeof x);
#define ll long long
const int maxn = 1e5+10;
string str1="X++",str2="++X",str3="X--",str4="--X";
int main(){int n,i,x=0;char a[150][3];while(~scanf ("%d",&n)){x = 0;for (i=0;i<n;i++){scanf ("%s",a[i]);x=x+(a[i][1]=='+'?1:-1);//判断输入的是'+'or'-'}printf ("%d\n",x);}return 0;
}

ZCMU-1428: Bit++ (水)相关推荐

  1. zcmu之水题来一波~

    1036: Shepherd 1112: 对于数字的强迫症 1137: 最后一次队内赛的a+b 1278: Sequence(哈希) 1279: Sort photos(读题) 1653: 这样真的好 ...

  2. [ZCMU OJ]5252: 英雄卡/5253: 排队接水/5254: 颜色叠加/5255: 勤劳的老杨/5256: 秘密大厦的访客

    5252: 英雄卡 Time Limit: 2 Sec  Memory Limit: 128 MB Submit: 133  Solved: 12 [Submit][Status][Web Board ...

  3. 【BZOJ】初级水题列表——献给那些想要进军BZOJ的OIers

    BZOJ初级水题列表--献给那些想要进军BZOJ的OIers 顺便纪念我的BZOJ 50_Problems_ACCEPTED 代码长度解释一切! 注:以下代码描述均为C++ RunID User Pr ...

  4. 吸水间最低动水位标高_水库水位库容监测系统方案

    一.前 言 水利行业在中国有着悠久的历史.随着国民经济的迅猛发展,水利工程在国民经济中所起的作用越来越大,防汛更是直接影响国民经济发展的一个重要方面.我国有水库8万座左右.众所周知,水库在防洪.兴利上 ...

  5. 2022-2028年中国遇水膨胀橡胶行业市场研究及前瞻分析报告

    [报告类型]产业研究 [出版时间]即时更新(交付时间约3个工作日) [发布机构]智研瞻产业研究院 [报告格式]PDF版 本报告介绍了遇水膨胀橡胶行业相关概述.中国遇水膨胀橡胶行业运行环境.分析了中国遇 ...

  6. LeetCode简单题之柠檬水找零

    题目 在柠檬水摊上,每一杯柠檬水的售价为 5 美元.顾客排队购买你的产品,(按账单 bills 支付的顺序)一次购买一杯. 每位顾客只买一杯柠檬水,然后向你付 5 美元.10 美元或 20 美元.你必 ...

  7. 喵哈哈村的魔法考试 Round #1 (Div.2) 题解源码(A.水+暴力,B.dp+栈)

    A.喵哈哈村的魔法石 发布时间: 2017年2月21日 20:05   最后更新: 2017年2月21日 20:06   时间限制: 1000ms   内存限制: 128M 描述 传说喵哈哈村有三种神 ...

  8. 水题/poj 1852 Ants

    1 /* 2 PROBLEM:poj1852 3 AUTHER:Nicole 4 MEMO:水题 5 */ 6 #include<cstdio> 7 using namespace std ...

  9. ZOJ 2723 Semi-Prime ||ZOJ 2060 Fibonacci Again 水水水!

    两题水题: 1.如果一个数能被分解为两个素数的乘积,则称为Semi-Prime,给你一个数,让你判断是不是Semi-Prime数. 2.定义F(0) = 7, F(1) = 11, F(n) = F( ...

  10. 《OpenCV3编程入门》学习笔记6 图像处理(五)漫水填充

    6.5 漫水填充(floodFill) 6.5.1 漫水填充 1.定义:一种用特定的颜色填充连通区域,通过设置可连通像素的上下限及连通方式达到不同填充效果 2.基本思想:自动选中和种子点相连的区域(位 ...

最新文章

  1. 异常处理中throws和throw的区别?
  2. 技术动态 | 知识图谱构建的研究已走入下半场,但大规模落地应用仍需时间
  3. SSL常用专业缩略语汇总
  4. 普林斯顿大学计算机科学研究生条件,普林斯顿大学之计算机科学系
  5. 数据网站(数据集的获取)、打分网站
  6. 简单的Oracle触发器使用
  7. 在ASP中常见的错误80004005信息和解决办法
  8. 已加密的PDF怎么解密?只要学会这两招即可轻松解密
  9. ONVIF协议开发使用
  10. python做生物信息学分析_Python从零开始第五章生物信息学⑤生存分析(log-rank)
  11. js鼠标经过与离开事件
  12. python中系统找不到指定文件怎么办_python 系统找不到指定的文件
  13. python项目打包部署到ios_Python实现iOS自动化打包详解
  14. DPM目标检测算法(毕业论文节选)
  15. Lotus Notes 7.0找不到服务器路径
  16. linux计划任务如何关闭程序,Linux进程控制和计划任务管理
  17. CMD窗口下进入PowerShell和退出PowerShell
  18. mysql identity sqlserver_mysql和sqlserver的区别
  19. 一种效果很好的自动白平衡技术(WhiteBalance)
  20. 大雁塔,青龙寺,樱花舞,落尘香

热门文章

  1. 速达开发版ERP移动端 App 操作使用说明
  2. 阿里云香港机器被攻击了怎么办?
  3. LAMP 技术简介(5)
  4. 红米note3android5.0,小米红米note3MOSBeta5.0安卓8.1.0来去电归属农历等本地化增强适配...
  5. xp系统打印机服务器报错,互联网要点:Win7系统连接XP共享打印机报错0X000004如何解决...
  6. OpenSSL-SNI
  7. 物理学原理与工程应用期末复习之公式总结
  8. 网络跳线接续的四种方法
  9. 通信网实验_Kruskal算法_Mininet_Ryu
  10. 生命是一个无解的谜——《我喜欢生命本来的样子》读后感作文2100字