Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program agendaelet;
- uses crt;
- type
- contato=record
- nome:string;
- telefone:integer;
- end;
- var
- agenda:array[1..100] of contato;
- Procedure Menu(Op1,Op2,Op3,Op4:string; var escolha:integer);
- begin
- Writeln('------Menu------');
- writeln(Op1);
- writeln(Op2);
- writeln(Op3);
- writeln(Op4);
- writeln(' Digite a opção desejada');
- readln(escolha);
- end;
- Procedure inserir(Mens1,Mens2:string; var num:integer;nom:string);
- begin
- writeln (Mens1);
- readln(nom);
- writeln (Mens2);
- readln(num);
- end;
- Procedure Ordenar;
- begin
- end;
- Procedure Busca(fim:integer;mensBus,buscado,achado:string; var valor:integer);
- Var
- parar:boolean;
- indice:integer;
- begin
- indice:=0;
- parar:=false;
- writeln(mensBus);
- readln(buscado);
- Repeat
- For indice:=1 to fim do
- begin
- If UpCase(buscado) = UpCase(achado) then
- parar:=true
- Else
- parar:=false;
- end;
- parar:=true
- until parar = true;
- valor:=indice;
- end;
- var
- nomepesquisa,nomenovo:string;
- telnovo:integer;
- op,qnt,i:integer;
- sn:char;
- Begin
- writeln('Bem Vindo a sua Agenda Eletrônica!!');
- qnt:=0;
- Repeat
- qnt:=qnt+1;
- inserir('Digite o Contato','Digite o Telefone do Contato';contato[qnt].nome;contato[qnt].telefone);
- writeln (' Deseja inserir outro contato? ');
- readln(sn);
- until (sn= 'n') or (qnt=100);
- ordenar;
- Repeat
- menu('1- Editar um Contato','2- Procurar Contato','3- Listar todos os Contatos','4- Fechar o programa',op);
- Case op Of
- 1 :
- begin
- For i:=1 to qnt do
- begin
- If contato[i].numero = 0 then
- inserir('Digite o Contato','Digite o Telefone do Contato';contato[i].nome;contato[i].telefone);
- ordenar;
- else If
- writeln(' A agenda esta cheia, delete algum contato');
- end;
- end;
- 2 :
- begin
- Busca(qnt,'Digite o Contato a ser Procurado',nomepesquisa,contato[i].nome;i);
- writeln('Nome: ',contato[i-1].nome, 'Telefone: ',contato[i-1].telefone);
- writeln('Nome: ',contato[i].nome, 'Telefone: ',contato[i].telefone);
- writeln('Nome: ',contato[i+1].nome, 'Telefone: ',contato[i+1].telefone);
- end;
- 3 :
- begin
- Busca(qnt,'Digite o Contato a ser Editado',nomepesquisa,contato[i].nome;i);
- writeln('Deseja alterar o nome do Contato? Digite: s(Sim)/n-(Não)');
- readln(sn);
- If sn= 's' then
- begin
- writeln('Digite o novo nome do contato');
- readln(nomenovo)
- contato[i].nome:=nomenovo;
- end
- else If sn='n' then
- writeln('Deseja alterar o numero do contato?');
- readln(sn)
- If sn='s' then
- begin
- writeln('Digite o numero novo de: ',contato[i].nome);
- readln(telnovo);
- contato[i].telefone:=telnovo;
- end
- else
- end;
- end;
- end;
- until op = 4;
- End.
Add Comment
Please, Sign In to add comment