Bit++

简介: Bit++

文章目录

一、Bit++

总结


一、Bit++

本题链接:Bit++


题目:


A. Bit++

time limit per test1 second

memory limit per test256 megabytes

inputstandard input

outputstandard output

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.


Examples

inputCopy

1

++X

output

1

input

2

X++

–X

output

0


本博客给出本题截图:

image.png

AC代码

#include <iostream>
#include <string>
using namespace std;
const int N = 160;
string a[N];
int n, x;
int main()
{
  cin >> n;
  for (int i = 0; i < n; i ++ ) 
  {
    cin >> a[i];
    if (a[i][0] == '+' || a[i][a[i].size() - 1] == '+')
      x ++;
    else x --;
  }
  cout << x << endl;
  return 0;
}

题意:就是看输入的字符串中是由 + 还是 - ,有 + 就是 + 1 ,有 - 就是 - 1

总结

水题,不解释


目录
相关文章
|
存储 传感器 编解码
ROS机器视觉入门:从基础到人脸识别与目标检测
前言 从本文开始,我们将开始学习ROS机器视觉处理,刚开始先学习一部分外围的知识,为后续的人脸识别、目标跟踪和YOLOV5目标检测做准备工作。我采用的笔记本是联想拯救者游戏本,系统采用Ubuntu20.04,ROS采用noetic。 颜色编码格式,图像格式和视频压缩格式 (1)RGB和BGR:这是两种常见的颜色编码格式,分别代表了红、绿、蓝三原色。不同之处在于,RGB按照红、绿、蓝的顺序存储颜色信息,而BGR按照蓝、绿、红的顺序存储。 rgb8图像格式:常用于显示系统,如电视和计算机屏幕。 RGB值以8 bits表示每种颜色,总共可以表示256×256×256=16777216种颜色
674 70
|
Web App开发 数据采集 JavaScript
我们来看一个基本的`pyppeteer`使用示例,包括`launch()`和`newPage()`方法。
我们来看一个基本的`pyppeteer`使用示例,包括`launch()`和`newPage()`方法。
|
人工智能
探秘写歌词的技巧和方法:让你的文字唱出旋律,妙笔生词AI智能写歌词软件
在音乐世界里,歌词是触动人心的灵魂。本文介绍如何掌握写歌词的技巧,包括灵感捕捉、结构布局、语言运用等,并推荐《妙笔生词智能写歌词软件》作为创作助手,助你轻松创作动人心弦的歌词。
|
缓存 运维 Java
解决Spring Boot中的内存泄漏问题
解决Spring Boot中的内存泄漏问题
|
机器学习/深度学习 PyTorch TensorFlow
Python实现深度学习学习率指数衰减的方法与参数介绍
学习率指数衰减提供了一种高效的动态调整学习率的手段,帮助模型在不同训练阶段以不同的学习速度优化,有利于提升模型性能和训练效率。通过合理设置衰减策略中的参数,可以有效地控制学习率的衰减过程,实现更加精确的模型训练调优。
872 0
|
机器学习/深度学习 数据采集 自然语言处理
【ChatGPT】ChatGPT是如何训练得到的?
【ChatGPT】ChatGPT是如何训练得到的?
378 1
|
编解码 API 开发工具
NV21、NV12、YV12、RGB565、YUV等颜色编码格式区别和接口设计探讨
NV21、NV12、YV12、RGB565、YUV分别是不同的颜色编码格式,这些颜色编码格式各有特点,适用于不同的应用场景。选择合适的颜色编码格式取决于具体的需求和环境:
781 1
|
算法
详尽分享算法系列:日历算法
详尽分享算法系列:日历算法
899 0
|
Java Spring
IDEA 创建 SpringCloud项目-多项目方式
IDEA 创建 SpringCloud项目-多项目方式
1248 0
|
移动开发 前端开发 HTML5
『html5、css3』将视频做为网页背景 超炫!
效果图展示 仿墨迹天气首页 github项目地址:https://github.com/Ethan997/Video-background-page PC端网页效果预览:http://www.
5490 0