|
|
вернуться в форумwhat is wrong in my code (WA №2)? What is wrong in my code? Please, give me a hint. var k,i,min,max,voices,sum:integer; ka:array [1..101] of integer; begin readln(k); for i:= 1 to k do begin read(ka[i]); if i=1 then begin min:=ka[i]; max:=ka[i]; end else begin if ka[i]<min then min:=ka[i]; if ka[i]>max then max:=ka[i]; end; end;
if min<>max then begin for i:=1 to k do begin if ka[i]=min then sum:=sum+ka[i]; end; voices:=sum div 2 +1; end else begin for i:=1 to k do sum:=sum+ka[i]; voices:=sum div 2 +1; end;
writeln(voices); end. Re: what is wrong in my code (WA №2)? Try this test: 3 1 3 9995 Re: what is wrong in my code (WA №2)? answer : 3? Re: what is wrong in my code (WA №2)? Yes |
|
|