-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1089.cpp
More file actions
54 lines (47 loc) · 1.27 KB
/
1089.cpp
File metadata and controls
54 lines (47 loc) · 1.27 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <iostream>
#include <vector>
using namespace std;
int main(){
int amostras;
while(true){
int seq;
int aux=0;
char direcao;
vector<int> loop;
cin >> amostras;
if(amostras == 0) break;
for(int i=0; i<amostras; i++){
cin >> seq;
loop.push_back(seq);
}
for(int j=0; j<loop.size(); j++){
if(j==0 && loop[loop.size()-1] > loop[j]){
direcao = 'B';
}
if(j==0 && loop[loop.size()-1] < loop[j]){
direcao = 'C';
}
if(j==loop.size()-1){
if(loop[j] > loop[0] && direcao != 'B'){
aux++;
direcao = 'B';
}
if (loop[j] < loop[0] && direcao != 'C'){
aux++;
direcao = 'C';
}
} else {
if(loop[j+1] > loop[j] && direcao != 'C') {
aux++;
direcao = 'C';
}
if(loop[j+1] < loop[j] && direcao != 'B'){
aux++;
direcao = 'B';
}
}
}
cout << aux << endl;
}
return 0;
}