Find Your Solution Here

Codeforces

Codeforces solution 282A – Bit++

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

#include <iostream>
#include <string>

using namespace std;

int main()
{
    int n, x(0);
    cin >> n;

    string s;
    while (n--)
    {
        cin >> s;
        if (s[1] == '+')
        {
            ++x;
        }
        else
        {
            --x;
        }
    }

    cout << x << endl;
    return 0;
}

2 Comments

  1. #include
    int main()
    {
    int n,i, x=0;

    char s[100];
    scanf(“%d”,&n);
    for(i=0;i<n;i++)
    {
    scanf("%s",s);
    if (s[1] == '+')
    {
    x++;
    }
    else
    {
    x–;
    }
    }

    printf("%d",x);
    return 0;
    }

Leave a Reply