Advertisement
hocikto19

9.1

Nov 24th, 2014
414
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.49 KB | None | 0 0
  1. // uloha-9-1.c -- Tyzden 9 - Uloha 1
  2. // Michal Kovacik, 20.11.2014 11:55:27
  3.  
  4. #include <stdio.h>
  5.  
  6. int main(){
  7.   int pred2, pred1, max, kolko, akt, i, temp;
  8.   while(scanf("%d", &kolko)>0){
  9.       pred2=0;
  10.       scanf("%d", &pred1);
  11.       max=pred1;
  12.       for(i=1; i<kolko; i++){
  13.           scanf("%d", &akt);
  14.           max=((pred2=pred2+akt)<pred1)? pred1:pred2;
  15.           temp = pred1;
  16.           pred1=max;
  17.           pred2=temp;
  18.       }
  19.       printf("%d\n", max);
  20.   }
  21.   return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement