Thursday, January 28, 2016

UVA 11878 | | Homework Checker

#include<iostream>
#include<string>
#include<cstring>
#include<cstdio>
#include<string>
#include<cctype>
#include<stdlib.h>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
    char s[100],p,q;
    int a,b, i ,cnt=0, k;
    while(scanf("%d%c%d%c%s",&a,&p,&b,&q,s)==5){
          //cin>>a>>p>>b>>q>>s;
    if(s[0]!='?'){
        if(p=='+'){
            if(a+b==atoi(s))
                cnt++;
        }
        else if(p=='-')
            if(a-b==atoi(s))
                cnt++;
    }
    }
    cout<<cnt<<"\n";
    cnt=0;

    return 0;
}

No comments:

Post a Comment