Задача такова: В первой строке входного файла INPUT.TXT записаны три натуральных числа через пробел. (по ограничениям числа могут не влезть в longint т.е. долгая арифметика). Вот мой код, во-первых не выполняется - вылазить стек оверфлоу еррор (даже на маленьких примерах) во-вторых работала не правильно. Так вот помогите разобраться...
Program ABBA;
Var A,B,C,R,P:array [1..10000] of byte;
ac,bc,cc,u:integer;
Procedure OpenFiles;
begin
assign(input,'input.txt');
assign(output,'output.txt');
reset(input);
rewrite(output);
end;
Procedure Caser;
Var t:char;
i,o: integer;
begin
i:=0;
read(input,t);
while t<>' ' do
begin
case t of
'0': A[o]:=0;
'1': A[o]:=1;
'2': A[o]:=2;
'3': A[o]:=3;
'4': A[o]:=4;
'5': A[o]:=5;
'6': A[o]:=6;
'7': A[o]:=7;
'8': A[o]:=8;
'9': A[o]:=9;
end;
Inc(i);
read(input,t);
end;
ac:=i+1;
i:=0;
read(input,t);
while t<>' ' do
begin
case t of
'0': B[o]:=0;
'1': B[o]:=1;
'2': B[o]:=2;
'3': B[o]:=3;
'4': B[o]:=4;
'5': B[o]:=5;
'6': B[o]:=6;
'7': B[o]:=7;
'8': B[o]:=8;
'9': B[o]:=9;
end;
Inc(i);
read(input,t);
end;
bc:=i+1;
i:=0;
read(input,t);
repeat
case t of
'0': C[o]:=0;
'1': C[o]:=1;
'2': C[o]:=2;
'3': C[o]:=3;
'4': C[o]:=4;
'5': C[o]:=5;
'6': C[o]:=6;
'7': C[o]:=7;
'8': C[o]:=8;
'9': C[o]:=9;
end;
Inc(i);
read(input,t);
until eof(input);
cc:=i;
END;
Procedure WriteM(M:array of byte;g:longint);
Var k:integer;
begin
for k:=1 to g do write(output,M[k]);
end;
Procedure Vubor(X,Y:array of byte;q:integer);
Var h,v,w:integer;
begin
while X[h]=Y[h] do Inc(v);
If X[v]>Y[v] then
begin
for w:=1 to q do R[w]:=X[w];
end;
If Y[v]>X[v] then
begin
for w:=1 to q do R[w]:=Y[w];
end;
end;
BEGIN
OpenFiles;
Caser;
if (ac>bc) and (ac>cc) then WriteM(A,ac);
if (bc>ac) and (bc>cc) then WriteM(B,bc);
if (cc>ac) and (cc>bc) then WriteM(C,cc);
if (ac=bc) and (ac>cc) then
begin
Vubor(A,B,ac);
WriteM(R,ac);
end;
if (ac=cc) and (ac>bc) then
begin
Vubor(A,C,ac);
WriteM(R,ac);
end;
if (bc=cc) and (bc>ac) then
begin
Vubor(B,C,bc);
WriteM(R,bc);
end;
if (ac=bc) and (ac=cc) then
begin
Vubor(A,B,ac);
for u:=1 to ac do P[u]:=R[u];
Vubor(C,P,ac);
WriteM(R,ac);
end;
END.
Примечание:
получить надо большее
Примечание:
Поменял код на такой и все-таки: Откуда Error 202: Stack Overflow Error
Program ABBA;
Var A,B,C,R,P:array [1..10000] of byte;
ac,bc,cc,u,h,v,w:integer;
Procedure OpenFiles;
begin
assign(input,'input.txt');
assign(output,'output.txt');
reset(input);
rewrite(output);
end;
Procedure Caser;
Var t:char;
i: integer;
begin
i:=1;
read(input,t);
while t<>' ' do
begin
case t of
'0': A[i]:=0;
'1': A[i]:=1;
'2': A[i]:=2;
'3': A[i]:=3;
'4': A[i]:=4;
'5': A[i]:=5;
'6': A[i]:=6;
'7': A[i]:=7;
'8': A[i]:=8;
'9': A[i]:=9;
end;
Inc(i);
read(input,t);
end;
ac:=i;
i:=1;
read(input,t);
while t<>' ' do
begin
case t of
'0': B[i]:=0;
'1': B[i]:=1;
'2': B[i]:=2;
'3': B[i]:=3;
'4': B[i]:=4;
'5': B[i]:=5;
'6': B[i]:=6;
'7': B[i]:=7;
'8': B[i]:=8;
'9': B[i]:=9;
end;
Inc(i);
read(input,t);
end;
bc:=i;
i:=1;
read(input,t);
repeat
case t of
'0': C[i]:=0;
'1': C[i]:=1;
'2': C[i]:=2;
'3': C[i]:=3;
'4': C[i]:=4;
'5': C[i]:=5;
'6': C[i]:=6;
'7': C[i]:=7;
'8': C[i]:=8;
'9': C[i]:=9;
end;
Inc(i);
read(input,t);
until eof(input);
cc:=i-1;
END;
Procedure WriteM(M:array of byte;g:integer);
Var k:integer;
begin
for k:=1 to g do write(output,M[k]);
end;
Procedure Vubor(X,Y:array of byte;q:integer);
begin
while X[h]=Y[h] do Inc(v);
If X[v]>Y[v] then
begin
for w:=1 to q do R[w]:=X[w];
end;
If Y[v]>X[v] then
begin
for w:=1 to q do R[w]:=Y[w];
end;
end;
BEGIN
OpenFiles;
Caser;
if (ac>bc) and (ac>cc) then WriteM(A,ac);
if (bc>ac) and (bc>cc) then WriteM(B,bc);
if (cc>ac) and (cc>bc) then WriteM(C,cc);
if (ac=bc) and (ac>cc) then
begin
Vubor(A,B,ac);
WriteM(R,ac);
end;
if (ac=cc) and (ac>bc) then
begin
Vubor(A,C,ac);
WriteM(R,ac);
end;
if (bc=cc) and (bc>ac) then
begin
Vubor(B,C,bc);
WriteM(R,bc);
end;
if (ac=bc) and (ac=cc) then
begin
Vubor(A,B,ac);
for u:=1 to ac do P[u]:=R[u];
Vubor(C,P,ac);
WriteM(R,ac);
end;
END.
Примечание:
НАШЕЛ ОШИБКИ И НАПИСАЛ ТАКОЙ КОД. ПРОГРАММА РЕЗУЛЬТАТ НЕ ВЫДАЕТ
Program ABBA;
Var A,B,C,R:array [1..5] of byte;
ac,bc,cc,u,h,v,w,max:integer;
Procedure Null;
Var q:integer;
begin
for q:=1 to max do
begin
A[q]:=0;
B[q]:=0;
C[q]:=0;
R[q]:=0;
end;
end;
Procedure OpenFiles;
begin
assign(input,'input.txt');
assign(output,'output.txt');
reset(input);
rewrite(output);
end;
Procedure Caser;
Var t:char;
i: integer;
begin
i:=1;
read(input,t);
while t<>' ' do
begin
case t of
'0': A[i]:=0;
'1': A[i]:=1;
'2': A[i]:=2;
'3': A[i]:=3;
'4': A[i]:=4;
'5': A[i]:=5;
'6': A[i]:=6;
'7': A[i]:=7;
'8': A[i]:=8;
'9': A[i]:=9;
end;
Inc(i);
read(input,t);
end;
ac:=i-1;
i:=1;
read(input,t);
while t<>' ' do
begin
case t of
'0': B[i]:=0;
'1': B[i]:=1;
'2': B[i]:=2;
'3': B[i]:=3;
'4': B[i]:=4;
'5': B[i]:=5;
'6': B[i]:=6;
'7': B[i]:=7;
'8': B[i]:=8;
'9': B[i]:=9;
end;
Inc(i);
read(input,t);
end;
bc:=i-1;
i:=1;
repeat
read(input,t);
case t of
'0': C[i]:=0;
'1': C[i]:=1;
'2': C[i]:=2;
'3': C[i]:=3;
'4': C[i]:=4;
'5': C[i]:=5;
'6': C[i]:=6;
'7': C[i]:=7;
'8': C[i]:=8;
'9': C[i]:=9;
end;
Inc(i);
until eof(input);
cc:=i-1;
END;
Procedure WriteM(M:array of byte;g:integer);
Var k:integer;
begin
for k:=1 to g do write(output,M[k]);
end;
Procedure Vubor(X,Y:array of byte;q:integer);
begin
v:=1;
while X[v]=Y[v] do Inc(v);
If X[v]>Y[v] then
begin
for w:=1 to q do R[w]:=X[w];
end;
If Y[v]>X[v] then
begin
for w:=1 to q do R[w]:=Y[w];
end;
end;
BEGIN
max:=5;
OpenFiles;
Caser;
if (ac>bc) and (ac>cc) then WriteM(A,ac);
if (bc>ac) and (bc>cc) then WriteM(B,bc);
if (cc>ac) and (cc>bc) then WriteM(C,cc);
if (ac=bc) and (ac>cc) then
begin
Vubor(A,B,ac);
WriteM(R,ac);
end;
if (ac=cc) and (ac>bc) then
begin
Vubor(A,C,ac);
WriteM(R,ac);
end;
if (bc=cc) and (bc>ac) then
begin
Vubor(B,C,bc);
WriteM(R,bc);
end;
if (ac=bc) and (ac=cc) then
begin
Vubor(A,B,ac);
Vubor(C,R,ac);
WriteM(R,ac);
end;
END.