/ Vijos / 讨论 / 问答 /

pascal谁拿了最多奖学金 求检错

老是跳步hidden steps,要不然就报错。。。求帮助
###源代码
var qm,bg,lw,mn,bj:array[1..100] of integer;
i,j,n,y,z:integer;
x,zongfen:longint;
c:string[100];
b:string[100];
xb:string[100];
gb:string[100];
begin

readln(n);
for i:=1 to n do
read(c[i]);
read(qm[i]);
read(bj[i]);
read(gb[i]);
read(xb[i]);
read(lw[i]);
for i:=1 to n do
begin
if (qm[i]>80) and (lw[i]>=1) then mn[i]:=mn[i]+8000;
if (qm[i]>85) and (bj[i]>80) then mn[i]:=mn[i]+4000;
if (qm[i]>90) then mn[i]:=mn[i]+2000;
if (xb[i]='Y') and (qm[i]>85) then mn[i]:=mn[i]+1000;
if (bj[i]>80) then mn[i]:=mn[i]+850;
end;
j:=0;
for i:=1 to n do zongfen:=zongfen+mn[i];
for i:=1 to n do
begin
if mn[i]>j then
begin
j:=mn[i];
b:=c[i];
y:=mn[i];
z:=zongfen;
end;
end;
end.

2 条评论

  • @ 2014-02-08 15:23:36

    read读字符串会出错的。建议先readln一行再做处理:
    type student=record
    nam:string;
    mar,cla,art:longint;
    wes,lea:boolean;
    end;
    var a:array[1..100] of student;
    f:array[1..100] of longint;
    n,ans,max,maxj:longint;
    procedure init;
    var i:longint;
    c:char;
    begin
    readln(n);
    for i:=1 to n do begin
    a[i].nam:='';
    read(c);
    while c<>' ' do begin
    a[i].nam:=a[i].nam+c;
    read(c);
    end;
    read(a[i].mar);
    read(a[i].cla);
    read(c);
    read(c);
    if (c='Y')or(c='y') then a[i].lea:=true else a[i].lea:=false;
    read(c);
    read(c);
    if (c='Y')or(c='y') then a[i].wes:=true else a[i].wes:=false;
    readln(a[i].art);
    end;
    end;
    procedure main;
    var i:longint;
    begin
    max:=-maxlongint;
    for i:=1 to n do begin
    f[i]:=0;
    if (a[i].mar>80)and(a[i].art>=1) then inc(f[i],8000);
    if (a[i].mar>85)and(a[i].cla>80) then inc(f[i],4000);
    if a[i].mar>90 then inc(f[i],2000);
    if (a[i].mar>85)and(a[i].wes=true) then inc(f[i],1000);
    if (a[i].cla>80)and(a[i].lea=true) then inc(f[i],850);
    inc(ans,f[i]);
    if f[i]>max then begin
    max:=f[i];
    maxj:=i;
    end;
    end;
    end;
    procedure print;
    begin
    writeln(a[maxj].nam);
    writeln(f[maxj]);
    writeln(ans);
    end;
    begin
    init;
    main;
    print;
    end.

  • @ 2014-02-07 19:37:41

    program ex;
    var
    d,i,j,k,m,n,p,number:integer;
    s1:string;
    a:array[1..100] of string;
    c:array[1..100] of string;
    ganbu:array[1..100] of string;
    xibu:array[1..100] of string;
    b:array[1..100,1..3] of longint;
    t:array[1..100] of longint;
    max,sum:extended;
    begin
    readln(d);
    k:=0;
    for i:=1 to d do
    readln(a[i]);
    for i:=1 to d do
    begin
    n:=0;
    p:=0;
    m:=0;
    inc(m);
    inc(k);
    j:=pos(' ',a[i]);
    c[k]:=copy(a[i],1,j-1);
    delete(a[i],1,j);
    while m<6 do
    begin
    inc(m);
    case m of
    2..3:begin
    inc(p);
    j:=pos(' ',a[i]);
    s1:=copy(a[i],1,j-1);
    val(s1,b[i,p]);
    delete(a[i],1,j);
    end;
    4..5:begin
    j:=pos(' ',a[i]);
    s1:=copy(a[i],1,j-1);
    if m=4 then ganbu[i]:=s1;
    if m=5 then xibu[i]:=s1;
    delete(a[i],1,j);
    end
    else begin inc(p);val(a[i],b[i,p]);end;
    end;
    end;
    end;
    for i:=1 to d do
    begin
    if (b[i,1]>80) and (b[i,3]>=1) then t[i]:=t[i]+8000;
    if (b[i,1]>85) and (b[i,2]>80) then t[i]:=t[i]+4000;
    if b[i,1]>90 then t[i]:=t[i]+2000;
    if (b[i,1]>85) and (xibu[i]='Y') then t[i]:=t[i]+1000;
    if (b[i,2]>80) and (ganbu[i]='Y') then t[i]:=t[i]+850;
    end;
    max:=t[1];
    number:=1;
    for i:=2 to d do
    begin
    if t[i]>max then begin max:=t[i];number:=i;end;
    end;
    writeln(c[number]);
    writeln(max:0:0);
    for i:=1 to d do
    sum:=sum+t[i];
    writeln(sum:0:0);
    end.

  • 1