-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathp314.c
28 lines (27 loc) · 768 Bytes
/
p314.c
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
/* Temperaturas extremas */
#include <stdio.h>
#include <string.h>
int main() {
int numCasos, numTemperaturas, temperaturas[10000], i, temperaturaAnterior, numPicos, numValles;
scanf("%d", &numCasos);
while(numCasos--) {
scanf("%d", &numTemperaturas);
memset(temperaturas, 0, sizeof(temperaturas));
numPicos = 0;
numValles = 0;
for(i = 0; i < numTemperaturas; i++) {
scanf("%d", &temperaturas[i]);
if(i > 1) {
if(temperaturaAnterior < temperaturas[i-2])
if(temperaturaAnterior < temperaturas[i])
numValles++;
if(temperaturaAnterior > temperaturas[i-2])
if(temperaturaAnterior > temperaturas[i])
numPicos++;
}
temperaturaAnterior = temperaturas[i];
}
printf("%d %d\n", numPicos, numValles);
}
return 0;
}