forked from Harshita-Kanal/Data-Structures-and-algorithms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflip.cpp
More file actions
34 lines (33 loc) · 698 Bytes
/
flip.cpp
File metadata and controls
34 lines (33 loc) · 698 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
int n;
cin >> t;
while(t > 0){
cin >> n;
vector <long int> a;
long int item;
int i;
for( i = 0; i < n; i++){
cin >> item;
a.push_back(item);
}
int c1 = (n - 1)/2;
int c2 = (n - 1)/2;
for(i = 0; i < n; i ++){
if(a[i + 1] - a[i] >= 0){
c1 --;
}
else{
a[i] = -1 * a[i];
}
}
for( i = 0; i < n; i++){
cout << a[i] <<" ";
}
cout <<endl;
t = t - 1;
}
}