Var i, j, k : integer; a : array [0..9,0..9] of char; procedure U(i,j:integer); var c : char; begin c:=a[i,j]; a[i,j]:=' '; if (c='W')and(a[i+1,j]='B') then U(i+1,j); if (c='B')and(a[i+1,j]='W') then U(i+1,j); if (c='W')and(a[i-1,j]='B') then U(i-1,j); if (c='B')and(a[i-1,j]='W') then U(i-1,j); if (c='W')and(a[i,j+1]='B') then U(i,j+1); if (c='B')and(a[i,j+1]='W') then U(i,j+1); if (c='W')and(a[i,j-1]='B') then U(i,j-1); if (c='B')and(a[i,j-1]='W') then U(i,j-1); end; begin assign(input,'input.txt'); reset(input); assign(output,'output.txt'); rewrite(output); for i:=1 to 8 do begin for j:=1 to 8 do read(a[i,j]); readln end; for i:=1 to 8 do begin a[0,i]:=' '; a[9,i]:=' '; a[i,0]:=' '; a[i,9]:=' ' end; k:=0; for i:=1 to 8 do for j:=1 to 8 do if a[i,j]<>' ' then begin k:=k+1; U(i,j) end; write(k); close(output) end.
Var m : array[0..6] of Integer; i,k,N : Integer; Begin For i:=0 to 6 do m[i]:=0; Readln(N); k:=6; While N>0 do Begin If N>=Power(2,k) then Begin N:=N-Trunc(Power(2,k)); Inc(m[k]); end else Dec(k); end; For i:=0 to 6 do Writeln(Power(2,i),' ',m[i],' шт.'); end.
Еще вариант: Const NN = 7; money : array[1..7] of Integer = (1,2,4,8,16,32,64); Var m : array[1..NN] of Integer; i,k,N : Integer; Begin For i:=1 to NN do m[i]:=0; Readln(N); k:=NN; While N>0 do Begin If N>=money[k] then Begin N:=N-money[k]; Inc(m[k]); end else Dec(k); end; For i:=1 to NN do Writeln(money[i],' ',m[i],' шт.'); end.
А что делать то???!?!?!