Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
461 B
0
Indexable
Never
#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;
	}
}
Leave a Comment