• 谁拿了最多的奖学金pascal


    题目描述略,巨水无比

    View Code
     1 program sky;
    2 var
    3 n,i,k,kk,lun,ans : longint;
    4 c : char;
    5 s : string;
    6 f,q : array[0..1000] of longint;
    7 a : array[0..1000] of string[25];
    8 bj,bjj : boolean;
    9 procedure qs(l,r : longint );
    10 var
    11 i,j,z,zz : longint;
    12 tp,tpp,kk : longint;
    13 tps : string[25];
    14 begin
    15 i:=l; j:=r; kk:=random(r-l+1)+l;
    16 z:=f[kk]; zz:=q[kk];
    17 repeat
    18 while ((f[i]>z) or ((f[i]=z) and (q[i]<zz))) do inc(i);
    19 while ((f[j]<z) or ((f[j]=z) and (q[j]>zz))) do dec(j);
    20 if i<=j then
    21 begin
    22 tp:=f[i]; f[i]:=f[j]; f[j]:=tp;
    23 tpp:=q[i]; q[i]:=q[j]; q[j]:=tpp;
    24 tps:=a[i]; a[i]:=a[j]; a[j]:=tps;
    25 inc(i); dec(j);
    26 end;
    27 until i>j;
    28 if i<r then qs(i,r);
    29 if l<j then qs(l,j);
    30 end;
    31 begin
    32 readln(n);
    33 randomize;
    34 for i:=1 to n do q[i]:=i;
    35 for i:=1 to n do
    36 begin
    37 read(c);
    38 s:=c;
    39 while c<>' ' do begin read(c); s:=s+c; end;
    40 delete(s,length(s),1);
    41 a[i]:=s;
    42 read(k,kk);
    43 read(c); read(c);
    44 if c='Y' then bj:=true;
    45 read(c); read(c);
    46 if c='Y' then bjj:=true;
    47 readln(lun);
    48 if (k>80) and (lun<>0) then inc(f[i],8000);
    49 if (k>85) and (kk>80) then inc(f[i],4000);
    50 if (k>90) then inc(f[i],2000);
    51 if bjj and (k>85) then inc(f[i],1000);
    52 if bj and (kk>80) then inc(f[i],850);
    53 inc(ans,f[i]);
    54 bj:=false; bjj:=false;
    55 end;
    56 qs(1,n);
    57 writeln(a[1]);
    58 writeln(f[1]);
    59 writeln(ans);
    60 end.



    Runtimeerror了N次,快排打错了,哎,这都能错

    还有就是双关键字排序第二关键字按字符串大小写了一个。。没看题阿。。。。

    就这样吧。。。

  • 相关阅读:
    PHP迭代与递归实现无限级分类
    初衷
    基于laravel5.4 vue 和vue-element搭建的单页面后台CMS
    lenovo E431 win8系统 安装win7
    Word Break II
    LeetCode:Linked List Cycle II
    PG里如何查看表,索引,表空间,数据库大小
    美国软件工程师面试注意事项
    打印从1到1000的整数,无循环,不判断
    fatal: incorrect checksum in control file
  • 原文地址:https://www.cnblogs.com/skysun/p/2397685.html
Copyright © 2020-2023  润新知