Color in Pascal / C

0

I have the following region staining code using Pascal queue:

program coloracao;
uses crt, filas;
const dim = 5;
type imagem = array [0...dim+1, 0...dim+1] of integer;
const I: imagem = ((-1, -1, -1, -1, -1, -1, -1),
                   (-1,  2,  1,  1,  3,  3, -1),
                   (-1,  1,  3,  3,  2,  3, -1),
                   (-1,  3,  2,  2,  2,  3, -1),
                   (-1,  3,  2,  3,  2,  3, -1),
                   (-1,  3,  3,  2,  3,  3, -1), 
                   (-1, -1, -1, -1, -1, -1, -1));

procedure exiba (var I: imagem);
var x, y: integer;
begin
    for x:=1 to dim do
        begin
            for y:=1 to dim do
                begin
                    textcolor(I[x,y]);
                        write (I[x,y]);
                end;
            writeln;
        end;
end;


procedure insf (var I: imagem; x,y,n:integer; var F: fila);
begin
    I[x,y]:=n;
    enfileira (x,F);
    enfileira (y,F):
end;

procedure emf (var x, y:integer; var F: fila)
begin
    x:=desenfileira(F);
    y:=desenfileira(F);
end;

procedure colorir (var I: imagem; x,y,n: integer);
var F: fila;
    a: integer;
begin
    iniciaf(F);
    a:=I[x,y];
    insf(I,x,y,n,F);
    while not vaziaf(F) do
        begin 
        remf (x,y,F);
        if I[x-1,y]=a then insf (I, x-1, y, n, F);
        if I[x,y+1]=a then insf (I, x, y+1, n, F);
        if I[x+1,y]=a then insf (I, x+1, y, n, F);
        if I[x,y-1]=a then insf (I, x, y-1, n, F);
        end;
end;

begin
    clrscr;
    exiba(I);
    readln;
    colorir(I,3,3,1);
    exiba(I);
    readln;
end.

My question is: What mechanism would I use to colorize in C, following this scheme of coloring an array?

    
asked by anonymous 04.06.2015 / 15:39

0 answers