Saturday, October 22, 2016

12279 - Emoogle Balance Solution

Problem link-click here

this problem is very easy and for the beginners as well. just read the statements very carefully then i guess you will find the following line and this line is everything what you need to do.

"Emoogle Balance = number of times Emoogle is supposed to give a treat according to the book - number of times he has actually given the treat".

an accepted code is as follows:

#include<bits/stdc++.h>
using namespace std;

int main()
{
    int t,i=1;

    while(cin>>t && t!=0)
    {
        int a,c=0,c1=0;

        while(t--)
        {
            cin>>a;

            if(a==0)
            {
                c++;
            }
            else
            {
                c1++;
            }
        }

        cout<<"Case "<<i<<": "<<c1-c<<endl;

        i++;
    }

    return 0;
}

No comments:

Post a Comment