Advertisement
Guest User

Untitled

a guest
Feb 28th, 2020
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.60 KB | None | 0 0
  1. function sum (id, pr, n, a):
  2.     a := array (n)
  3.     count := 0
  4.     i := 0
  5.     j := 0
  6.     k := 0
  7.     for i := 0 until (n - 1):
  8.         for j := (i + 1) until n:
  9.             if (a[i] >= a[j]):
  10.                 k := a[j]
  11.                 a[j] := a[i]
  12.                 a[i] := k
  13.     while (count < n & a[count] < 0):
  14.         count += 1
  15.        
  16.     if (a[count] > 0):
  17.         print(0)
  18.    
  19.     else:
  20.         if (count == n):
  21.             print(0)
  22.         else:
  23.             while ((a[count + 1] - a[count]) == 1 | (a[count + 1] == a[count])):
  24.                 count += 1
  25.                 if (count == n):
  26.                     print(a[count - 1] + 1)        
  27.     print(a[count] + 1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement