var x,y: array [1..10000] of integer; u,t,i,N,S,max3,min3:integer; begin readln (N); for i:=1 to N do readln (x[i],y[i]); s:=0; max3:=0; min3:=maxint; for i:=1 to N do begin if x[i]>y[i] then t:=x[i]; u:=y[i] else t:=y[i]; u:=x[i] end; // <<< --- ВОТ ЗДЕСЬ! ПОМОГИТЕ! s:=s+t; if (u mod 3<>0) and (u>max3) then max3:=t; if (t mod 3=0) and (t<min3) then min3:=t; end; if S mod 3<>0 then writeln (s) else begin if (max3=0) or (min3=maxint) then writeln (0) else writeln (s-min3+max3) end. 

Closed due to the fact that off-topic participants Kromster , Streletz , Igor , pavel , Nicolas Chabanovsky 14 Oct '16 at 9:45 .

It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:

  • “Questions asking for help with debugging (“ why does this code not work? ”) Should include the desired behavior, a specific problem or error, and a minimum code for playing it right in the question . Questions without an explicit description of the problem are useless for other visitors. See How to create minimal, self-sufficient and reproducible example . " - Kromster, Streletz, Igor, Nicolas Chabanovsky
If the question can be reformulated according to the rules set out in the certificate , edit it .

  • 2
    It is necessary to get acquainted with the concept of "block" in imperative languages. Also, the rules for creating the “ladder” code will be useful, including to avoid such errors - 4per

4 answers 4

If it is trivial to format the code correctly, for example, like this, then you can see where the error (and not one) is:

 var x, y: array [1..10000] of integer; u, t, i, N, S, max3, min3 : integer; begin readln (N); for i := 1 to N do readln (x[i],y[i]); s := 0; max3 := 0; min3 := maxint; for i := 1 to N do begin if x[i] > y[i] then t:=x[i]; u:=y[i] else // <<< --- ВОТ ЗДЕСЬ! ПОМОГИТЕ! t:=y[i]; u:=x[i] end; s:=s+t; if (u mod 3<>0) and (u>max3) then max3:=t; if (t mod 3=0) and (t<min3) then min3:=t; end; if S mod 3<>0 then writeln (s) else begin if (max3=0) or (min3=maxint) then writeln (0) else writeln (s-min3+max3) end. 

And now correctly:

 var x, y: array [1..10000] of integer; u, t, i, N, S, max3, min3 : integer; begin readln (N); for i := 1 to N do readln (x[i],y[i]); s := 0; max3 := 0; min3 := maxint; for i := 1 to N do begin if x[i] > y[i] then begin t:=x[i]; u:=y[i]; // <-- Тут end else begin t:=y[i]; u:=x[i]; // <-- и тут... end; s:=s+t; if (u mod 3<>0) and (u>max3) then max3:=t; if (t mod 3=0) and (t<min3) then min3:=t; end; //for i... if (S mod 3)<>0 then writeln (s) else begin if (max3=0) or (min3=maxint) then writeln (0) else writeln (s-min3+max3); end; //<--- нужно было добавить end. 

Look like that's it. Use operator brackets begin..end not hesitating, and do not be lazy to indent (the ladder), it is not in vain that it was invented.

  • Damn, what would I do without you! Thank you, take note! - TaumCkBep

After the then operator there should be only one operator. If more are needed, they must be placed inside the begin...end compound statement begin...end

 if x[i]>y[i] then begin t:=x[i]; u:=y[i]; end else begin t:=y[i]; u:=x[i]; end; 
  • and this is the correct answer) - 4per
  • @ 4per, suddenly :-) - Grundy
  • Ohhhhh, thank you very much! - TaumCkBep
  • If it were not for you, it is not known how much I would have broken my head in search of a solution. True there are still errors, but minor! Thank you very much! - TaumCkBep

Your program should look like this. You forgot a very simple thing: when you perform several actions under one condition (in your case, if ), they must be between begin .. end

Working version of your program:

 var x,y: array [1..10000] of integer; u,t,i,N,S,max3,min3:integer; begin readln (N); for i:=1 to N do readln (x[i],y[i]); s:=0; max3:=0; min3:=maxint; for i:=1 to N do begin if x[i]>y[i] then begin t:=x[i]; u:=y[i]; end else begin t:=y[i]; u:=x[i]; end; end; s:=s+t; if (u mod 3<>0) and (u>max3) then max3:=t; if (t mod 3=0) and (t<min3) then min3:=t; end; if S mod 3<>0 then writeln (s) else if (max3=0) or (min3=maxint) then writeln (0) else writeln (s-min3+max3); end. 
  • if S mod 3<>0 then writeln (s) else begin still no closing end; - Embedder pm
  • @Embedder is probably not the case, this begin is not needed there, because nested if is essentially 1 action :) - Legionary
  • If “rephrasing” like this, then yes - not needed. And do not forget to put after writeln (s-min3+max3) ; . - Embedder
  • @Embedder but it seems to me to compile without it - 4per
  • @ 4per In principle, yes - before end ; you can not put, but somehow it is not for Feng Shui :) - Embedder

Well, it is written in Russian that it is necessary to put a semicolon before the else (at the end of the previous command) u:=y[i];

  • not. do not. the error is not in it. - 4per
  • Well, I already did that, I still give an error, but do not put a semicolon before an else? - TaumCkBep
  • Try to write more detailed answers. Explain what is the basis of your statement? - Nicolas Chabanovsky