Untitled
unknown
plain_text
2 years ago
461 B
3
Indexable
#include <iostream> int main() { int arr[100]; int counter = 0; int t = 0; int a = 0; int b = 0; int localMax = 0; int input = 1; while (input != 0) { std::cin >> input; arr[counter] = input; counter++; } std::cin >> t; for (int i = 0; i < t; i++) { std::cin >> a >> b; for (int j = a - 1; j < b; j++) { if (arr[j] > localMax) { localMax = arr[j]; } } std::cout << localMax; localMax = 0; } }
Editor is loading...
Leave a Comment