fork download
  1. program wardrobe3;
  2. Uses Strutils;
  3. const MAX = 5000000;
  4. type elenco = array[1..MAX] of string[1];
  5. var m,k,i :qword;
  6. numero : qword;
  7. cifre, A : Ansistring;
  8. ccifre : array[1..MAX] of integer;
  9. potenzadieci : array [0..MAX] of qword;
  10. arrnum:array [1..MAX] of string[1];
  11.  
  12. procedure scambia (var x,y: string);
  13. var t:string;
  14. begin
  15. t:=x;
  16. x:=y;
  17. y:=t;
  18. end;
  19. Procedure ordinamento (estremoi,estremos: qword; var v : elenco; ordinato:boolean);
  20. var inf, sup, medio:qword;
  21. pivot :string[1];
  22. begin
  23. inf:=estremoi;
  24. sup:=estremos;
  25. medio:= (estremoi+estremos) div 2;
  26. pivot:=v[medio];
  27. repeat
  28. if (ordinato) then
  29. begin
  30. while (v[inf]<pivot) do inf:=inf+1;
  31. while (v[sup]>pivot) do sup:=sup-1;
  32. end;
  33. if inf<=sup then
  34. begin
  35. scambia(v[inf],v[sup]);
  36. inf:=inf+1;
  37. sup:=sup-1;
  38. end;
  39. until inf>sup;
  40. if (estremoi<sup) then ordinamento(estremoi,sup,v,ordinato);
  41. if (inf<estremos) then ordinamento(inf,estremos,v,ordinato);
  42. end;
  43. begin
  44. readln(m,k);
  45. readln(cifre);
  46. A:=ReverseString(cifre); writeln (A);end.
  47. for i:=1 to m do arrnum[i]:=copy(cifre,i,1);
  48. potenzadieci[0]:=1; numero:=0;
  49. for i:=1 to m do potenzadieci[i]:=(potenzadieci[i-1]*10);
  50. for i:=1 to m do begin numero:=numero + potenzadieci[m-i]*(ord(cifre[i]) - 48); end;
  51. ordinamento (1,m,arrnum, true); writeln('ciao');
  52.  
  53. end.
Success #stdin #stdout 0s 5320KB
stdin
6 3
123042
stdout
240321