Advertisement
Josif_tepe

Untitled

Nov 14th, 2022
708
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.69 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4.  
  5. int main() {
  6.     int x;
  7.     int prethoden_broj;
  8.     int prv = 0;
  9.     int maksimalen_zbir = 0;
  10.     int reden_broj;
  11.     int red = 0;
  12.     while(scanf("%d", &x)) {
  13.         red++;
  14.         if(prv == 0) {
  15.             prethoden_broj = x;
  16.             prv = 1;
  17.         }
  18.         else {
  19.             if(x < 0 && prethoden_broj < 0) {
  20.                 break;
  21.             }
  22.             if(maksimalen_zbir < prethoden_broj + x) {
  23.                 maksimalen_zbir = prethoden_broj + x;
  24.                 reden_broj = red;
  25.             }
  26.             prethoden_broj = x;
  27.         }
  28.     }
  29.     printf("%d %d", reden_broj, reden_broj - 1);
  30.    
  31.     return 0;
  32. }
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement