Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main() {
- int n;
- printf("Enter the length of the row: ");
- scanf("%d", &n);
- int arr[n];
- printf("Enter the row of numbers:\n");
- for (int i = 0; i < n; i++) {
- scanf("%d", &arr[i]);
- }
- int start = 0, end = 0, max_len = 1, curr_len = 1;
- for (int i = 1; i < n; i++) {
- if (arr[i] > arr[i - 1]) {
- curr_len++;
- if (curr_len > max_len) {
- max_len = curr_len;
- end = i;
- start = end - max_len + 1;
- }
- } else {
- curr_len = 1;
- }
- }
- printf("The longest increasing underrow is: ");
- for (int i = start; i <= end; i++) {
- printf("%d ", arr[i]);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement