Saturday, December 9, 2017

UVa problem solution 12854 - Automated Checking Machine

problem link:

Discuss: in this problem you can easily use two array. compare the array with each element if they are same then it is not compatible otherwise it is compatible


try yourself before see the code


 #include<bits/stdc++.h>
using namespace std;
int main()
{
   int outlet[10];
    while(cin >>outlet[0]>>outlet[1]>>outlet[2]>>outlet[3]>>outlet[4])
    {
        int plug[10],i,j,cnt,p=0,o=0,flag=0;
        for(i=0;i<5;i++)
        {
          cin >>plug[i];
        }
            for(i=0;i<5;i++)
            {
                if(outlet[i]==plug[i])
                    flag=1;

            }
            if(!flag)
                cout <<"Y"<<endl;
            else
                cout <<"N"<<endl;

    }
    return 0;
}

No comments:

Post a Comment