Compare the Triplets || HackerRank
Problem name: Compare the Triplets
Judge: HackerRank
Problem link: Compare the Triplets
Solution on GitHub: Compare the Triplets
[At first you should try to solve the problem on your own. This will increase your thinking power and the ability to solve the program will increase. And if you copy directly from here, you will not learn anything. So my advice is to try to solve it yourself first. If not then check this code. Once you understand the code, do it yourself. Don't copy from here.
Best of luck]
Solution in C++/Cpp
#include <iostream>
using namespace std;
int main()
{
int array1[3], array2[3], i, count1 = 0, count2 = 0;
for (i = 0; i < 3; i++)
{
cin >> array1[i];
}
for (i = 0; i < 3; i++)
{
cin >> array2[i];
}
for (i = 0; i < 3; i++)
{
if (array1[i] > array2[i]) count1++;
else if (array1[i] < array2[i]) count2++;
}
cout << count1 << " " << count2 << endl;
return 0;
}
