Advertisement
Guest User

Untitled

a guest
Jan 17th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. program es6pag7;
  2. var
  3. V,P,D:array[1..40]of integer;
  4. i,j,cp,cd,t:integer;
  5. procedure input;
  6. begin
  7. writeln('Dammi 40 numeri');
  8. for i:=1 to 40 do
  9. readln(V[i]);
  10. end;
  11. procedure separazione;
  12. begin
  13. for i:=1 to 40 do
  14. begin
  15. if(V[i] mod 2=0)then
  16. begin
  17. V[i]:=P[cp];
  18. cp:=cp+1;
  19. end
  20. else
  21. begin
  22. V[i]:=D[cd];
  23. cd:=cd+1;
  24. end;
  25. end;
  26. procedure ordinamento;
  27. begin
  28. v:=false;
  29. repeat
  30. for i:=1 to cp do
  31. for j:=1 to cp-1 do
  32. if(P[j]<P[j+1])then
  33. begin
  34. t:=P[j];
  35. P[j]:=P[j+1];
  36. P[j+1]:=t;
  37. end;
  38. for i:=1 to cd do
  39. for j:=1 to cd-1 do
  40. if(D[j]<D[j+1])then
  41. begin
  42. t:=D[j];
  43. V[j]:=D[j+1];
  44. D[j+1]:=t;
  45. end;
  46. end;
  47. procedure output
  48. begin
  49. input;
  50. cp:=1;
  51. cd:=1;
  52. separazione;
  53. ordinamento;
  54. output;
  55. readln;
  56. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement