A solution in c++
#include<bits/stdc++.h>
using namespace std;
int arr[1000],brr[1006];
int main()
{
int T;
cin >> T;
for (int t = 1; t <= T; ++t)
{
int n;
cin >> n;
int increase(0), decrease(0);
int previous, current;
cin >> previous;
for (int i = 1; i < n; ++i)
{
cin >> current;
if (current > previous)
++increase;
else if (current < previous)
++decrease;
previous = current;
}
cout << "Case " << t << ": " << increase << " " << decrease <<'\n';
}
}


2 Comments
This problem is good. I didn't solved it when I was beginner but It's a good problem for beginners. But I think you should avoid writing all those Header files below . It really looks ugly and it's unnecessary. Because contains all those headers. :)
ReplyDeleteThanks for comment in my site.
DeleteNext time i try to avoid unnecessary headers. :)
If you have any doubts, Please let me know