Jump to content

Lista Telefónica


cibersoft
 Share

Recommended Posts

Boa tarde gostava de saber se me podem ajudar com esta lista telefónica.

Program agenda (input,output);
uses crt;
type agendas = record
     nom,morada:string[50];
     telem,fixo:integer ;
     end;
var age:array[1..1]of agendas;
     i,j:integer;
     dados1:text;
     op:char;
     label inicio;
begin
{agenda telefónica by Nelson}
textbackground(blue);
clrscr;
textcolor(white);
     writeln('                                AGENDA TELEFONICA                ');
     inicio:
     writeln();
      assign ( dados1, 'contactos.txt');
rewrite(dados1);
     for i:=1 to 2 do
         begin
         write(' Nome : ');
         readln(age[i].nom);
         writeln();
         write('Morada : ');
         readln(age[i].morada);
         writeln(dados1,age[i].nom);
         writeln();
         writeln(dados1,age[i].morada);
         end;
         for j:=1 to 1 do
         writeln();
         write('N. Telemovel : ');
         readln(age[j].telem);
         writeln();
         write('N. Telefone: ');
         readln(age[j].fixo);
         writeln(dados1,age[j].telem);
         writeln(dados1,age[j].fixo);
         writeln('\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\///////////////////////////////');
          close(dados1);
          reset(dados1);
          while not eof (dados1) do
                begin
                repeat
                readln(dados1,age[i].nom);
                readln(dados1,age[i].morada);
                readln(dados1,age[j].telem);
                readln(dados1,age[j].fixo);
                writeln(age[i].nom);
                writeln();
                writeln(age[i].morada);
                writeln();
                writeln(age[j].telem);
                writeln();
                writeln(age[j].fixo);
                until (op)= readkey ;
                end;
                close (dados1);


      readkey;
end.

O que eu queria é que ao introduzir os dados ele fosse perguntando se quer continuar, e no fim desse para previsualizar os dados introduzidos.

Até agora foi esse o código que introduzi, preciso de uma ajuda.

Obrigado

😁

Link to comment
Share on other sites

Pois isso não sei muito bem, podiam explicar.

O que fiz foi isto, e já tá melhor.

Program agenda (input,output);
uses crt;
type agendas = record
     nom,morada:string[50];
     telem,fixo:integer ;
     end;
var age:array[1..1]of agendas;
     i,j:integer;
     dados1:text;
     op:char;
     op1: integer;
     label inicio;
Procedure entrada;
begin
{agenda telefónica by Nelson}
textbackground(blue);
clrscr;
textcolor(white);
     writeln('                                AGENDA TELEFONICA                ');
     inicio:
     writeln();
      assign ( dados1, 'contactos.txt');
append(dados1);
     for i:=1 to 1 do
         begin
         write(' Nome : ');
         readln(age[i].nom);
         writeln();
         write('Morada : ');
         readln(age[i].morada);
         writeln(dados1,age[i].nom);
         writeln();
         writeln(dados1,age[i].morada);

         writeln();
         write('N. Telemovel : ');
         readln(age[i].telem);
         writeln();
         write('N. Telefone: ');
         readln(age[i].fixo);
         writeln(dados1,age[i].telem);
         writeln(dados1,age[i].fixo);
         writeln('\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\///////////////////////////////');
          close(dados1);
end;
end;
Procedure ler;
begin
      assign ( dados1, 'contactos.txt');
          reset(dados1);
             for i:=1 to 1 do
         begin
          while not eof (dados1) do
                begin
                repeat
                readln(dados1,age[i].nom);
                readln(dados1,age[i].morada);
                readln(dados1,age[i].telem);
                readln(dados1,age[i].fixo);
                writeln(age[i].nom);
                writeln();
                writeln(age[i].morada);
                writeln();
                writeln(age[i].telem);
                writeln();
                writeln(age[i].fixo);
                until (op)= readkey ;
                end;
                close (dados1);
                end;


      readkey;
end;
begin
repeat
writeln('qual a op');
readln(op1);
case op1 of
1: entrada;
2: ler;
end;
until op1=3;
end.

Digam alguma coisa, Obrigado. :wallbash:

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.