编写一个评分系统,接受用户输入10个选手的得分(0-10分),然后去掉一个最高分和一个最低分,求选手的最后得分(平均分)

program pinfeng;
var
    n, min, max, s:real;
    i:integer;
begin
    read(n);
    min := n;
    max := n;
    s := n;
    for i := 1 to 9 do
    begin
        read(n);
        if n<min then
            min := n;
        if n>max then
            max := n;
        s := s+n;
    end;
    writeln((s-max-min)/8:0:2)
end.

=============== OR ======================

program pinfeng;
var
  n, min, max, s : real;
  i:integer;
begin
  write('Please enter 10 numbers: ');
  read(n);
  min := n;
  max := n;
  s := n;
  for i := 1 to 9 do
  begin
      read(n);
      s := s+n;
      if n < min then
        min := n
      else if n > max then
        max := n;
  end;
  writeln('Avg: ', (s-max-min)/8 : 0 : 2);
  readln();
  readln();
end.

====================== OR ===================

program pinfeng;
var
  n, min, max, s : real;
  i:integer;
begin
  min := 10;
  max := -10;
  s := 0;
  write('Please enter 10 numbers: ');
  for i := 1 to 10 do
  begin
      read(n);
      s := s+n;
      if n < min then
        min := n;
      if n > max then
        max := n;
  end;
  writeln('Avg: ', (s-max-min)/8 : 0 : 2);
  readln();
  readln();
end.
posted @ 2010-01-01 18:34  SmartIOI  阅读(638)  评论(0)    收藏  举报
本站采用CC授权如需转载、引用文章,请务必附上作者及来源处。 Creative Commons License