- 谁拿了最多奖学金
- 2016-06-09 14:30:45 @
谁给个数据?
ps:样例数据要按回车才算输入完成,会不会数据里没回车?
```Pascal
type list=record
name:string;
markqm,markbj,lw,s:longint;
ganbu,xibu:boolean;
end;
var a:array[0..101] of list;
n,i,k,l:longint;
b:char;
procedure sort(l,r: longint);
var
i,j,x: longint;
y:list;
begin
i:=l;
j:=r;
x:=a[(l+r) div 2].s;
repeat
while a[i].s<x do
inc(i);
while x<a[j].s do
dec(j);
if not(i>j) then
begin
y:=a[i];
a[i]:=a[j];
a[j]:=y;
inc(i);
j:=j-1;
end;
until i>j;
if l<j then
sort(l,j);
if i<r then
sort(i,r);
end;
begin
readln(n);
for i:=1 to n do
with a[i] do
begin
read(b);
l:=1;
while b<>' ' do
begin
name[l]:=b;
read(b);
inc(l);
end;
name[0]:=chr(l);
read(markqm,markbj);
read(b);
read(b);
if b='Y' then ganbu:=true else ganbu:=false;
read(b);
read(b);
if b='Y' then xibu:=true else xibu:=false;
read(b);
read(lw);
readln;
end;
k:=0;
for i:=1 to n do
with a[i] do
begin
s:=0;
if (markqm>80) and (lw>=1) then inc(s,8000);
if (markqm>85) and (markbj>80) then inc(s,4000);
if (markqm>90) then inc(s,2000);
if (xibu) and (markqm>85) then inc(s,1000);
if (markbj>80) and (ganbu) then inc(s,850);
inc(k,s);
end;
sort(1,n);
writeln(a[n].name);
writeln(a[n].s);
writeln(k);
end.
```
8 条评论
-
yangsaibin LV 7 @ 2016-10-30 22:32:17
我也是这个情况
-
2016-10-03 13:57:02@
program ex8;
var na:array[1..100,1..21] of char;
a,b,sch,f:array[1..100] of integer;
c,d:array[1..100] of char;
i,j,n,max,sum,asd,code:integer;
ch:char;
sr:string;
begin
read(n);
for i:=1 to n do
sch[i]:=0;
sum:=0;
max:=0;
for i:=1 to n do
for j:=1 to 21 do
begin
read(na[i,j]);
if (na[i,j]=' ') then
begin
read(a[i],b[i]);
read(sr);
c[i]:=sr[2];
d[i]:=sr[4];
delete(sr,1,5);
val(sr,f[i],code);
break;
end;
end;
for i:=1 to n do
begin
if (a[i]>80) and (f[i]>=1) then sch[i]:=sch[i]+8000;
if (a[i]>85) and (b[i]>=80) then sch[i]:=sch[i]+4000;
if a[i]>90 then sch[i]:=sch[i]+2000;
if (a[i]>85) and (d[i]='Y') then sch[i]:=sch[i]+1000;
if (b[i]>80) and (c[i]='Y') then sch[i]:=sch[i]+850;
end;
for i:=1 to n do
begin
sum:=sum+sch[i];
if sch[i]>max then
begin
max:=sch[i];
asd:=i;
end;
end;
for i:=1 to 21 do
if na[asd,i]<>' ' then write(na[asd,i])
else break;
writeln;
writeln(sch[asd]);
writeln(sum);
end.
同样WA -
2016-08-05 13:12:15@
c++代码
-
2016-08-05 13:11:36@
#include<stdio.h> #include<string.h> #include<iostream> using namespace std; long long n,total=0; int q; struct { char s[21]; int fen,Class,ganbu,xibu,lunwen; long monny; }xyz[101]; void putin() { int i; scanf("%lld",&n); for(i=1;i<=n;i++){ char a1,b1; scanf("%s %d %d %c %c %d",&xyz[i].s,&xyz[i].fen,&xyz[i].Class,&a1,&b1,&xyz[i].lunwen); if(a1=='Y') xyz[i].ganbu=1; else xyz[i].ganbu=0; if(b1=='Y') xyz[i].xibu=1; else xyz[i].xibu=0; } } void work() { int i; for(i=1;i<=n;i++) xyz[i].monny=0; for(i=1;i<=n;i++){ if(xyz[i].fen>80 && xyz[i].lunwen>=1) xyz[i].monny+=8000; if(xyz[i].fen>85 && xyz[i].Class>80) xyz[i].monny+=4000; if(xyz[i].fen>90) xyz[i].monny+=2000; if(xyz[i].fen>85 && xyz[i].xibu==1) xyz[i].monny+=1000; if(xyz[i].Class>80 && xyz[i].ganbu==1) xyz[i].monny+=850; total+=xyz[i].monny; } } void work2() { long Max=0; int i; for(i=1;i<=n;i++) if(xyz[i].monny>Max){ q=i; Max=xyz[i].monny; } } void putout() { printf("%s\n",&xyz[q].s); cout<<xyz[q].monny<<"\n"; cout<<total; } int main() { putin(); work(); work2(); putout(); return 0; }
-
2016-08-05 09:53:04@
自己写错了
-
2016-07-27 12:44:13@
还要用排序?!直接一个循环找最大就行啦
-
2016-07-25 20:32:41@
快排没稳定性 位置交换了 怎么能对啊
-
2016-06-09 15:46:07@
数据末尾是有回车的~
- 1