Monday, May 30, 2016

CODEFORCES problem 282/A Bit++

Problem link (Click here)

#include <iostream>
#include <cstdio>
#include<cstdlib>
#include <string>

using namespace std;

int main()
{
    string ch;
    int n;
    int x=0;
    cin >> n;
    while(n--){
        cin>>ch;
        if(ch[0]=='+' || ch[1]=='+'){
            x++;
        }
        else
            x--;
    }
    cout<< x <<endl;

    return 0;
}

2 comments:

  1. #include
    int main()
    {
    int n,x=0;
    char c[100],a[4]="X++",b[4]="++X";
    scanf("%d",&n);
    while(n--)
    {
    getchar();
    gets(c);
    if(strcmp(c,a)==0 || strcmp(c,b)==0)
    {
    x++;
    }
    else
    x--;
    }
    printf("%d\n",x);
    return 0;
    }

    ReplyDelete