Advertisement
Guest User

Untitled

a guest
Mar 28th, 2020
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. var n,m,i,k,x,y,d,l,st:longint;
  2. A:array [0..20,0..20] of longint;
  3. BEGIN
  4. read(n,m);
  5. for i:=1 to n do
  6. begin
  7. for k:=1 to m do
  8. read(A[i,k]);
  9. writeln();
  10. end;
  11. for i:=1 to n do
  12. for k:=1 to m do
  13. begin
  14. if (A[i+1,k]=0) then
  15. d:=A[i,k+1]+A[i,k]
  16. else
  17. begin
  18. if (A[i+1,k]>A[i,k+1]) then
  19. d:=A[i,k+1]+A[i,k]
  20. else
  21. d:=A[i+1,k]+A[i,k];
  22. if (A[i,k+1]=0) then
  23. d:=A[i+1,k]+A[i,k]
  24. else
  25. begin
  26. if (A[i+1,k]>A[i,k+1]) then
  27. d:=A[i,k+1]+A[i,k]
  28. else
  29. d:=A[i+1,k]+A[i,k];
  30. end;
  31. end;
  32. end;
  33. writeln(d);
  34. END.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement