[ atlas @ 03.01.2006. 21:10 ] @
NZS i NZD za n brojeva


Code:
PROGRAM NZD_NZS (INPUT,OUTPUT);
USES CRT;
label 1,2,3;
VAR x:ARRAY[1..9] OF LONGINT;
    n,i,max,min,a,b:longint;
BEGIN
clrscr;
WRITELN('KOLKO BROJEVA');
READ(N);
MAX:=1;
for i:=1 to n DO BEGIN
WRITELN('UNESI ',I,'. BROJ');
READ(X[I]);
IF MAX<X[I] then max:=x[i];
end;min:=x[1];
for i:=2 to n do begin
if x[i]<min then min:=x[i];
end;
1: a:=0;
for i:=1 to n do begin
if max mod x[i]<>0 then a:=a+1;
end;
if a>0 then max:=max+1;goto 1; if a=0 then goto 2;
2: b:=0;
for i:=1 to n do begin
if x[i] mod min<>0 then b:=b+1; end;
if b>0 then min:=min-1; goto 2;
if b=0 then goto 3;
3: writeln;
WRITELN('NZS=',MAX);
WRITELN('NZD=',MIN);
END.



nako pokretanja zablokira mi dos.........



[Ovu poruku je menjao atlas dana 03.01.2006. u 22:13 GMT+1]
[ Passwd @ 03.01.2006. 21:24 ] @
1.Sta ti treba radit taj kod uopce..?
2.Nikad ne koristi GOTO
3.Ako vec koristis GOTO onda je dobro stavit:

Code:

1:BEGIN
   //kod
   END;

2:BEGIN
   //kod
   END;

...
[ ntojzan @ 03.01.2006. 21:33 ] @
Blokira zbog onog "goto 1"

Inace to se ne koristi u Pascalu, batali to...

Inace trebao si ovako: (samo taj deo)

if A > 0 then
begin
Max := Max + 1;
goto 1;
end;

Moguce je da imas jos neke greske, ali kod ti je uzasno formatiran, pa sam jedva i ovo primetio...