zoukankan      html  css  js  c++  java
  • Pascal到c++,求大佬翻译!

    请大佬翻译完毕后私信我谢谢!

    var
      a,b,c,d,f:array[1..1000]of longint;
      i,j,k,n,m,o:longint;
    procedure zx(p,q:longint);
    var
      i,j:longint;
    begin
      i:=0;
      while (i/(q-p+1))<(o/100) do
      begin
        inc(i);
        k:=k+b[p+i-1]+1;
        if i=1 then dec(k);
        a[d[p+i-1]]:=b[p+i-1]+1;
        if a[d[p+i-1]]>m then a[d[p+i-1]]:=m;
      end;
      if (p+i-1)=q then exit;
      for j:=p+i to q do a[d[j]]:=0;
    end;
    procedure qsort(l,r:longint);
    var
      i,j,mid,p,m1:longint;
    begin
      i:=l;j:=r;
      mid:=b[(l+r) div 2];
      m1:=d[(l+r) div 2];
      repeat
        while (b[i]<mid)or((b[i]=mid)and(d[i]<m1)) do inc(i);
        while (b[j]>mid)or((b[j]=mid)and(d[j]>m1)) do dec(j);
        if (i<=j) then
          begin
            p:=b[i]; b[i]:=b[j]; b[j]:=p;
            p:=d[i]; d[i]:=d[j]; d[j]:=p;
            inc(i);
            dec(j);
          end;
      until i>j;
      if l<j then qsort(l,j);
      if i<r then qsort(i,r);
    end;
    begin
      readln(n,m,o);
      for i:=n downto 1 do
      begin
         c[i]:=i;
         b:=a;
         if i<>n then for j:=n downto i+1 do f[j]:=a[j];
         d:=c;
         k:=0;
         if i<>n then qsort(i+1,n);
         fillchar(a,sizeof(a),0);
         if i<>n then zx(i,n);
         a[i]:=m-k;
         if a[i]<0 then 
         begin 
           for j:=n downto i+1 do a[j]:=f[j];
           a[i]:=-1;
          end;
      end;
      for i:=1 to n do write(a[i],' ');
    end.
    
    

    pascal->c++

    再次感谢大佬!

  • 相关阅读:
    最大值和最小值
    GetLevelDesc函数
    21. D3DSprite
    SetFileAttributes和GetFileAttributes
    24. 幕外渲染
    D3D修改view矩阵与修改world矩阵的区别
    23. 保存纹理(保存屏幕截图)
    C++之solmyr小品文
    C++二进制文件写操作
    22. 凸凹贴图
  • 原文地址:https://www.cnblogs.com/vercont/p/10210110.html
Copyright © 2011-2022 走看看