zoukankan      html  css  js  c++  java
  • 谁拿了最多的奖学金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次,快排打错了,哎,这都能错

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

    就这样吧。。。

  • 相关阅读:
    mybatis基础学习3---特殊sql语句(备忘)
    5.dos网络配置命令,重新获取ip刷新dns
    Guarded Suspension设计模式
    多线程Future设计模式
    多线程不可变对象设计模式immutable
    多线程读写锁分离设计模式
    多个人过门引出线程安全问题
    库存管理系统项目总结
    简单认识C#
    数据类型,变量,与运算符
  • 原文地址:https://www.cnblogs.com/skysun/p/2397685.html
Copyright © 2011-2022 走看看