Ir para conteúdo
Fórum Script Brasil
  • 0

Estou Com Dificuldade De Implementar Em C++ Esse Programa Em Pascal


protonto

Pergunta

sou iniciante em programaçao... tenho um programa que fiz em pascal e gostaria de implementar ele em C++

se alguém puder me ajudar agradeceria muito

segue abaixo o programa em pascal

program MEMORIA_SO;

uses CRT;

label

VOLTA;

label

VOLTAMEM;

label

VERNOME;

var

TPROC,I,J,AUX,CONT,CONT2,CONT3,PINIC,PFINAL,MEM,M,N,TALOC:integer;

NOMEPROC:string[1];

VERF_ALOC,VERF_TPROC:string;

TPROC1:real;

ALOC2:array[1..512]of string[1];

PROC2:array[1..512]of integer;

begin

clrscr;

MEM:=1024;CONT:=0;CONT2:=0;PINIC:=0;PFINAL:=0;AUX:=0;J:=0;N:=0;M:=0;

writeln('Digite o tamanho da Alocacao da Memoria: 2, 4, 8, 16, 32');

readln (VERF_ALOC);

{readln(TALOC);}

{while (TALOC <> 2) and (TALOC <> 4) and (TALOC <> 8) and (TALOC <> 16) and (TALOC <> 32) do}

while (VERF_ALOC <> '2') and (VERF_ALOC <> '4') and (VERF_ALOC <> '8') and (VERF_ALOC <> '16') and (VERF_ALOC <> '32') do

begin

textcolor(12);

writeln ('E R R O !!!! Digite o tamanho da Alocacao da Memoria: 2, 4, 8, 16, 32');

textcolor(white);

readln (VERF_ALOC);

{readln(TALOC);}

end;

val(VERF_ALOC,TALOC);

N:=(TALOC);

M:=(MEM div N);

if TALOC = N

then begin

for I:= 1 to M do

ALOC2:=('0');

textcolor(10);

writeln('Memoria disponivel: ',MEM);

textcolor(white);

writeln('Digite o Nome do Processo ');

readln (NOMEPROC);

NOMEPROC:= upcase(NOMEPROC);

while NOMEPROC = '' do

begin

writeln('Digite o Nome do Processo ');

readln (NOMEPROC);

NOMEPROC:= upcase(NOMEPROC);

end;

writeln('Digite o Tamanho do Processo');

readln (VERF_TPROC);

val(VERF_TPROC,TPROC1);

TPROC:=(trunc(TPROC1));

while (TPROC <= 0) or (TPROC > MEM) do

begin

if (TPROC > MEM) then begin

textcolor(12);

writeln('E R R O !!!!. Digite o Tamanho do Processo menor ou igual a: ',MEM);

textcolor(white);

readln (VERF_TPROC);

val(VERF_TPROC,TPROC1);

TPROC:=(trunc(TPROC1));

end

else begin

textcolor(12);

writeln('E R R O !!!!. Digite o Tamanho do Processo entre 0 e ',MEM);

textcolor(white);

readln (VERF_TPROC);

val(VERF_TPROC,TPROC1);

TPROC:=(trunc(TPROC1));

end;

end;

if (TPROC mod N)<> 0 then

TPROC:=((TPROC+(N-1)) div N)

else

TPROC:= TPROC div N;

while NOMEPROC <> '0' do

begin

for I:=1 to M do

if ALOC2='0'

then begin

inc(CONT);

inc(J);

PROC2[J]:= I ;

end;

if (CONT=0)

then begin

VOLTAMEM:

writeln(' ');

writeln(' ');

textcolor(12);

writeln('Memoria CHEIA: ',MEM);

writeln(' ');

textcolor(white);

writeln('Digite o Nome do Processo para FINALIZAR ou <0> para sair');

readln (NOMEPROC);

NOMEPROC:= upcase(NOMEPROC);

while NOMEPROC = '' do

begin

writeln('Digite o Nome do Processo para FINALIZAR ou <0> para sair ');

readln (NOMEPROC);

NOMEPROC:= upcase(NOMEPROC);

end;

TPROC:=0;

if NOMEPROC <> '0'

then begin

AUX:=0;

while AUX=0 do

begin

for I:=1 to M do

if ALOC2=NOMEPROC

then begin

inc(AUX);

inc(CONT);

ALOC2:='0';

end;

if AUX=0 then begin

writeln('E R R O !!! Processo não ativo. Digite um processo ATIVO para FINALIZAR');

readln (NOMEPROC);

NOMEPROC:= upcase(NOMEPROC);

while NOMEPROC = '' do

begin

writeln('E R R O !!! Processo não ativo. Digite um processo ATIVO para FINALIZAR');

readln (NOMEPROC);

NOMEPROC:= upcase(NOMEPROC);

end;

end;

end;

end

else begin

exit;

end;

{if (CONT < TPROC)then

goto VOLTA; }

end;

if (CONT >= TPROC)

then begin

PINIC:=PROC2[1];

PFINAL:=(PROC2[1]-1)+ TPROC ;

for I:=PINIC to PFINAL do

if ALOC2='0'

then begin

ALOC2:= (NOMEPROC);

end;

end;

{Verificação de Espaço Disponivel}

{clrscr;

VOLTA:

if (CONT < TPROC)

then begin

textcolor(12);

writeln(' ');

writeln('E R R O !!! Processo muito Grande');

writeln(' ');

end;}

{Imprimindo o Registro}

for I:=1 to M do

begin

if ALOC2<>'0'

then begin

textcolor(10);

write(' ',ALOC2);

end

else begin

textcolor(white);

write(' ',ALOC2);

end;

end;

for I:=1 to M do

begin

if ALOC2='0'then

inc(CONT2);

end;

MEM:=CONT2*N;

if MEM=0 then

goto VOLTAMEM;

writeln(' ');

writeln(' ');

textcolor(10);

writeln('MEM LIVRE: ',MEM);

writeln(' ');

textcolor(white);

writeln('Digite o Nome do Processo ou <0> para sair');

readln (NOMEPROC);

NOMEPROC:= upcase(NOMEPROC);

while NOMEPROC = '' do

begin

writeln('Digite o Nome do Processo ou <0> para sair');

readln (NOMEPROC);

NOMEPROC:= upcase(NOMEPROC);

end;

if NOMEPROC <>'0' then begin

CONT3:=0;

while CONT3=0 do

begin

for I:=1 to M do

begin

if ALOC2=NOMEPROC

then begin

GOTO VERNOME;

end;

end;

inc(CONT3);

VERNOME:

if CONT3=0 then begin

textcolor(white);

writeln('Processo ATIVO .Digite Nome de outro Processo ou <0> para sair');

readln (NOMEPROC);

NOMEPROC:= upcase(NOMEPROC);

while NOMEPROC = '' do

begin

writeln('Processo ATIVO .Digite Nome de outro Processo ou <0> para sair ');

readln (NOMEPROC);

NOMEPROC:= upcase(NOMEPROC);

end;

end;

if NOMEPROC='0' then exit;

end;

textcolor(white);

writeln('Digite o Tamanho do Processo');

readln (VERF_TPROC);

val(VERF_TPROC,TPROC1);

TPROC:=(trunc(TPROC1));

while (TPROC <= 0) or (TPROC > MEM) do

begin

if (TPROC > MEM) then begin

textcolor(12);

writeln('E R R O !!!!. Digite o Tamanho do Processo menor ou igual a: ',MEM);

textcolor(white);

readln (VERF_TPROC);

val(VERF_TPROC,TPROC1);

TPROC:=(trunc(TPROC1));

end

else begin

textcolor(12);

writeln('E R R O !!!!. Digite o Tamanho do Processo entre 0 e ',MEM);

textcolor(white);

readln (VERF_TPROC);

val(VERF_TPROC,TPROC1);

TPROC:=(trunc(TPROC1));

end;

end;

if (TPROC mod N)<> 0 then

TPROC:=((TPROC+(N-1)) div N)

else

TPROC:= TPROC div N;

CONT:=0;

CONT2:=0;

CONT3:=0;

PINIC:=0;

PFINAL:=0;

J:=0;

end;

end;

exit;

end;

end.

Link para o comentário
Compartilhar em outros sites

2 respostass a esta questão

Posts Recomendados

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,2k
    • Posts
      652k
×
×
  • Criar Novo...