Advertisement
Guest User

Untitled

a guest
Dec 22nd, 2014
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. var
  2. n,i,j,max,s,p,g:longint;
  3. a : array[1..1000] of longint;
  4. begin
  5. ReadLn(RandSeed, n);
  6. for i:=1 to n do
  7. begin
  8. a[i]:=5-Random(11);
  9. end;
  10.  
  11. max:=0;
  12. for i:=1 to n do
  13. begin
  14. s:=0;
  15. for j:=i to n do
  16. begin
  17. s:=s+a[j];
  18. if s > max then
  19. begin
  20. p:=i;
  21. g:=j;
  22. max:=s;
  23. end;
  24. end;
  25. end;
  26. writeln(p,' ',g,' ',max);
  27.  
  28. if n<10 then
  29. begin
  30. for i:=1 to n do
  31. begin
  32. if i<>n then write(a[i],' ')
  33. else write(a[i]);
  34. end;
  35. end;
  36. readln;
  37. End.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement