- 贪婪的送礼者
- 2009-07-07 20:24:47 @
program liwu;
type point=^node;
node=record
mame:string;
shou,chu:longint;
end;
var n,i:integer;
money,m,ch:longint;
a:array[1..10] of point;
s,b:string;
procedure give(num,z,np:longint);
var i,j:integer;
c:string;
begin
a[num]^.chu:=z-z mod np;
for i:=1 to np do
begin
readln(c);
for j:=1 to n do
if c=a[j]^.mame then a[j]^.shou:=a[j]^.shou+z div np;
end;
end;
begin
readln(n);
for i:=1 to n do begin readln(b);new(a[i]);
a[i]^.mame:=b;
a[i]^.chu:=0;
a[i]^.shou:=0;
end;
while not eof do
begin
readln(s);
readln(money,m);
if (money=0) or (m=0) then break;
for i:=1 to n do
if s=a[i]^.mame then give(i,money,m);
end;
for i:=1 to n do
begin
write(a[i]^.mame,' ');
ch:=a[i]^.shou-a[i]^.chu;
writeln(ch);
end;
end.
3 条评论
-
笑红尘 LV 7 @ 2009-10-27 22:08:35
干吗要用指针?!
-
2009-07-08 07:49:13@
chegxu
program aas;
var
s:array[1..10] of string;
p,j:string;
a,b,c,d,e,i,i1,i2,i3,i4:integer;
chu:array[1..10] of integer;
ru:array[1..10] of integer;
baoliu:array[1..10] of integer;
begin
readln(a);
for i:=1 to a do
readln(s[i]);
for i:=1 to a do
begin
readln(p);
for i1:=1 to a do if p=s[i1] then b:=i1;
read(chu);
readln(c);
if c0 then
begin
e:=chu div c;
baoliu:=chu mod c;
end
else
begin
e:=0;
baoliu:=chu;
end;
for i1:=1 to c do
begin
readln(j);
for i2:=1 to a do
if j=s[i2] then ru[i2]:=ru[i2]+e;
end;
end;
for i:=1 to a do
begin
write(s[i]);
write(' ');
writeln(ru[i]-chu[i]+baoliu[i]);
end;
end. -
2009-07-07 20:53:52@
这是什么题?
偶连题都不懂
- 1