URI Solution 1089 Musical Loop - Solution in C++ | Ad Hoc
Main Problem Link on URI - https://www.urionlinejudge.com.br/judge/en/problems/view/1089
URI Online Judge Solution | Ad Hoc
Problem Name: URI Problem - Musical Loop
Problem Number : URI - 1089
Online Judge : URI Online Judge Solution
Level: Ad Hoc
Solution Language : C plus plus
URI Solution 1089 Code in CPP:
#include <cstdio> int array[10005]; int main() { int n = 0; int i = 0; int x = 0; scanf("%d", &n); while(n != 0) { x = 0; for(i = 0; i < n; i++) { scanf("%d", &array[i]); } for(i = 0; i < n; i++) { if(array[i] < array[(i + 1)%n]) { if(array[(i + 1)%n] > array[(i + 2)%n]) { x++; } } if(array[i] > array[(i + 1)%n]) { if(array[(i + 1)%n] < array[(i + 2)%n]) { x++; } } } printf("%d\n", x); scanf("%d", &n); } return 0; }
No comments:
Write commentsTo know more about the problem, give us your valuable commment. We'll try to help you. Thanks