daily pastebin goal
15%
SHARE
TWEET

Untitled

a guest Aug 12th, 2017 49 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <cstdio>
  3. int main()
  4. {
  5. int t,i,tab[1000],suma,j;
  6.     scanf("%d",&t);
  7.     for (i=1; i<=t; i++)
  8.     {
  9.         scanf("%d",&tab[i]);
  10.     }
  11.     suma=0;
  12.     for (i=1; i<=t; i++)
  13.     {
  14.         if ((tab[1]>0)&&(tab[2]<0)) {tab[1]=0; tab[2]=0;}
  15.         else
  16.         if (tab[t]<0) tab[t]=0;
  17.         else
  18.         suma=suma+tab[i];
  19.     }
  20.     printf("%d\n",suma);
  21.  
  22. }
RAW Paste Data
Top