来源:程军康|编辑日期:2009-11-06 12:03:42|点击数: |发布:55
NOIP2005提高组解题报告
谁拿了最多奖学金(scholar)
题目概述:
已知每个学生的个人信息,求出获得奖学金最多的学生姓名、金额,以及全部奖学金金额。
算法分析:
模拟
其中涉及简单的字符处理,特别要注意数据类型的应用。如:学生姓名可采用char和string相结合的方法处理,奖学金金额用longint较为适宜。
程序:
program scholar;
var name:array[1..100] of string;
a1,a2,a5:array[1..100] of longint;
a3,a4:array[1..100] of char;
n,i,max,total,p:longint;
maxname:string;
ch:char;
f:text;
begin
assign(f,'scholar.in');reset(f);
readln(f,n);
for i:=1 to n do
begin
read(f,ch);
while ch<>' ' do
begin
name[i]:=name[i]+ch;
read(f,ch);
end;
readln(f,a1[i],a2[i],ch,a3[i],ch,a4[i],ch,a5[i]);
end;
close(f);
for i:=1 to n do
begin
p:=0;
if (a1[i]>80) and (a5[i]>=1) then inc(p,8000);
if (a1[i]>85) and (a2[i]>80) then inc(p,4000);
if (a1[i]>90) then inc(p,2000);
if (a1[i]>85) and (a4[i]='Y') then inc(p,1000);
if (a2[i]>80) and (a3[i]='Y') then inc(p,850);
if p>max then
begin
max:=p;
maxname:=name[i];
end;
inc(total,p);
end;
assign(f,'scholar.out');rewrite(f);
上一篇:
下一篇: