diff options
Diffstat (limited to 'c')
-rw-r--r-- | c/376_sietePicos.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/c/376_sietePicos.cpp b/c/376_sietePicos.cpp new file mode 100644 index 0000000..1fbeba9 --- /dev/null +++ b/c/376_sietePicos.cpp @@ -0,0 +1,29 @@ +#include <iostream> + +using namespace std; + +int main() { + int size; + int prev, next; + int picos; + cin>>size; // Primera lectura del tamaƱo fuera del bucle para primera comprobaciĆ³n + while (size != 0) { + int heights[size]; + // Lee todas las alturas + for (int i = 0; i < size; i++) { + cin>>heights[i]; + } + picos = 0; + // Comprueba todas las alturas + for (int i = 0; i < size; i++) { + prev = i-1; + if (prev < 0) + prev = size-1; + next = (i+1)%size; + if (heights[i] > heights[prev] && heights[i] > heights[next]) + picos++; + } + cout<<picos<<endl; + cin>>size; + } +} |