Guest User

Untitled

a guest
Jan 25th, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Oz 2.73 KB | None | 0 0
  1. program agendaelet;
  2. uses crt;
  3.  
  4. type
  5. contato=record
  6.     nome:string;
  7.     telefone:integer;
  8. end;
  9.  
  10. var
  11.     agenda:array[1..100] of contato;
  12.    
  13. Procedure Menu(Op1,Op2,Op3,Op4:string; var escolha:integer);
  14. begin
  15.     Writeln('------Menu------');
  16.     writeln(Op1);
  17.     writeln(Op2);
  18.     writeln(Op3);
  19.     writeln(Op4);
  20.     writeln(' Digite a opção desejada');
  21.     readln(escolha);
  22. end;
  23.        
  24. Procedure inserir(Mens1,Mens2:string; var num:integer;nom:string);
  25. begin
  26.         writeln (Mens1);
  27.         readln(nom);
  28.         writeln (Mens2);
  29.         readln(num);
  30. end;
  31.  
  32. Procedure Ordenar;
  33. begin
  34. end;
  35.  
  36. Procedure Busca(fim:integer;mensBus,buscado,achado:string; var valor:integer);
  37. Var
  38.     parar:boolean;
  39.     indice:integer;
  40. begin
  41.     indice:=0;
  42.     parar:=false;
  43.     writeln(mensBus);
  44.     readln(buscado);
  45.     Repeat
  46.         For indice:=1 to fim do
  47.         begin
  48.             If UpCase(buscado) = UpCase(achado) then
  49.             parar:=true
  50.             Else
  51.             parar:=false;
  52.         end;
  53.     parar:=true
  54.     until parar = true;
  55.     valor:=indice;
  56. end;
  57.  
  58. var
  59.     nomepesquisa,nomenovo:string;
  60.     telnovo:integer;
  61.     op,qnt,i:integer;
  62.     sn:char;
  63.  
  64. Begin
  65.     writeln('Bem Vindo a sua Agenda Eletrônica!!');
  66.     qnt:=0;
  67.     Repeat
  68.         qnt:=qnt+1;
  69.         inserir('Digite o Contato','Digite o Telefone do Contato';contato[qnt].nome;contato[qnt].telefone);
  70.         writeln (' Deseja inserir outro contato? ');
  71.         readln(sn);
  72.     until (sn= 'n') or (qnt=100);
  73.     ordenar;
  74.     Repeat
  75.         menu('1- Editar um Contato','2- Procurar Contato','3- Listar todos os Contatos','4- Fechar o programa',op);
  76.         Case op Of
  77.             1 :
  78.             begin
  79.                 For i:=1 to qnt do
  80.                 begin
  81.                     If contato[i].numero = 0 then
  82.                         inserir('Digite o Contato','Digite o Telefone do Contato';contato[i].nome;contato[i].telefone);
  83.                         ordenar;
  84.                     else If
  85.                     writeln(' A agenda esta cheia, delete algum contato');
  86.                 end;
  87.             end;
  88.             2 :
  89.             begin
  90.                 Busca(qnt,'Digite o Contato a ser Procurado',nomepesquisa,contato[i].nome;i);
  91.                 writeln('Nome: ',contato[i-1].nome, 'Telefone: ',contato[i-1].telefone);
  92.                 writeln('Nome: ',contato[i].nome, 'Telefone: ',contato[i].telefone);
  93.                 writeln('Nome: ',contato[i+1].nome, 'Telefone: ',contato[i+1].telefone);
  94.             end;
  95.             3 :
  96.             begin
  97.                 Busca(qnt,'Digite o Contato a ser Editado',nomepesquisa,contato[i].nome;i);
  98.                 writeln('Deseja alterar o nome do Contato? Digite: s(Sim)/n-(Não)');
  99.                 readln(sn);
  100.                 If sn= 's' then
  101.                 begin
  102.                     writeln('Digite o novo nome do contato');
  103.                     readln(nomenovo)
  104.                     contato[i].nome:=nomenovo;
  105.                 end
  106.                 else If sn='n' then
  107.                     writeln('Deseja alterar o numero do contato?');
  108.                     readln(sn)
  109.                     If sn='s' then
  110.                     begin
  111.                     writeln('Digite o numero novo de: ',contato[i].nome);
  112.                     readln(telnovo);
  113.                     contato[i].telefone:=telnovo;
  114.                     end
  115.                     else
  116.                 end;
  117.             end;
  118.         end;
  119.     until op = 4;
  120. End.
Add Comment
Please, Sign In to add comment