Advertisement
Guest User

kappa

a guest
Feb 21st, 2020
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.60 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. """
  3. Created on Fri Feb 21 15:04:42 2020
  4.  
  5. @author Abdallah Wahidi : 202003090
  6. """
  7.  
  8. listt = input("Enter the integers separated by a space.")
  9. L = listt.split()
  10. for i in range(0, len(L)):
  11.     L[i] = int(L[i])
  12.  
  13. maxx = L[0]
  14. a = 0
  15. b = 0
  16. for i in range(len(L)):
  17.     for j in range(i, len(L)):
  18.         summation = 0
  19.         for k in range(i, j + 1):
  20.             summation = summation + L[k]
  21.         if summation > maxx:
  22.               maxx = summation
  23.               a = i
  24.               b = j
  25. print(maxx)              
  26.  
  27. for i in range(a, b+1):
  28.     print(L[i], end=' ')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement