turbo Pascal不高兴的津津

来源:百度知道 编辑:UC知道 时间:2024/06/01 02:58:45
Program unhappy;
Const
infile = 'unhappy.in';
outfile = 'unhappy.out';
Var
a, b, k, i, max: Integer;
Begin
Assign(input, infile);
Reset(input);
max := 8; k := 0;
For i:=1 To 7 Do Begin
If max < a + b Then Begin
max := a + b; k := i;
End;
End;
Close(input);
Assign(output, outfile);
Rewrite(output);
WriteLn(k);
Close(output);
End.

实在是对不起...我真的看不出来哪里写得不对、
请高人指教。谢谢!
我改了一下...可是为什么最后unhappy.out出来的都是0呢?
请指教~!
Program unhappy;
Const
infile = 'unhappy.in';
outfile = 'unhappy.out';
Var
a, b, k, i, max: Integer;
Begin
Assign(input, infile);
Reset(input);
ReadLn(a, b);
For i:=1 To 7 Do Begin
max :=8; k :=0;
If max < a + b Then Begin
max := a + b; k := i;
End;
End;
Close(in

......
For i:=1 To 7 Do Begin
ReadLn(a,b);
If max < a + b Then Begin
......

额......

readln(a,b)还是放错位置了。
应该是这样:
Program unhappy;
Const
infile = 'unhappy.in';
outfile = 'unhappy.out';
Var
a, b, k, i, max: Integer;
Begin
Assign(input, infile);
Reset(input);
For i:=1 To 7 Do Begin
ReadLn(a, b);
max :=8; k :=0;
If max < a + b Then Begin
max := a + b; k := i;
End;
End;
Close(input);
Assign(output, outfile);
Rewrite(output);
WriteLn(k);
Close(output);
End.

Program unhappy;
Const
infile = 'unhappy.in';
outfile = 'unhappy.out';
Var
a, b, k, i, max: Integer;
Begin
Assign(input, infile);
Reset(input);
ReadLn(a, b);
max :=10000; k :=0;
For i:=1 To 7 Do Begin
If