Sunday, July 17, 2016

UVA 11878 Solution

Unknown
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
    int a,b,c,cnt=0,res;
    char sign, s[10];
    while (scanf("%d %c %d %s",&a,&sign,&b,s)!=EOF)
    {
        if (s[0]!='?')
        {
            int l=strlen(s);
            c=0;
            for (int i=1;i<l;i++) c=c*10+s[i]-'0';
            res=sign=='+'?a+b:a-b;
            if (res==c) cnt++;
        }
    }
    printf("%d\n",cnt);
    return 0;
}

Unknown

Studying at Shahjalal University of Science and Technology, Sylhet.

0 comments:

Post a Comment

Coprights @ 2016,