Advertisement
Guest User

Untitled

a guest
May 27th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.13 KB | None | 0 0
  1. //
  2. // Lista.cpp
  3. // ProjetoDicionario
  4. //
  5. // Created by Rafael Prado on 26/05/17.
  6. // Copyright © 2017 Rafael Prado. All rights reserved.
  7. //
  8.  
  9. #include<iostream>
  10. #include<iomanip>
  11. #include <stdlib.h>
  12. #include "Lista.h"
  13.  
  14. using namespace std;
  15.  
  16. //=====================================Cadastrar================================
  17.  
  18. void Cadastrar (noptr &lista)
  19. {
  20. noptr p;
  21. p = new No;
  22. cout << "Digite a palavra em portugues:" << endl;
  23. cin.ignore();
  24. cin >> p->Ptbr;
  25.  
  26. cout << "Enter the word in English:" << endl;
  27. cin.ignore();
  28. cin >> p->Eng;
  29.  
  30. if(lista == NULL)
  31. p->next = NULL;
  32.  
  33. else
  34. p->next = lista;
  35.  
  36. lista = p;
  37. }
  38.  
  39.  
  40. //======================================Listar====================================
  41.  
  42. void Listar (noptr &lista)
  43. {
  44. int p;
  45.  
  46. if (lista == NULL)
  47. {
  48. cout << endl;
  49. cout << "Fim da lista\n";
  50. cout << endl;
  51. }
  52.  
  53. else
  54. {
  55. cout << endl;
  56. cout << "Palavra em portugues: ";
  57. p = 0;
  58.  
  59. while(lista->Ptbr[p] != '\0')
  60. {
  61. cout << lista->Ptbr[p];
  62. p++;
  63. }
  64.  
  65. cout << endl;
  66. p = 0;
  67. cout << "Word in english: ";
  68. while(lista->Eng[p] != '\0')
  69. {
  70. cout << lista->Eng[p];
  71. p++;
  72. }
  73.  
  74. cout << endl;
  75. Listar(lista->next);
  76. cout << endl;
  77. }
  78. }
  79.  
  80. //=======================================Buscar==================================
  81.  
  82. void Buscar (noptr &lista, char vetbuscar[])
  83. {
  84. int i=0, j=0;
  85. No *p = lista;
  86.  
  87. while(vetbuscar[j] != '\0')
  88. {
  89. j++;
  90. }
  91.  
  92. if(p == NULL)
  93. cout << "Essa palavra nao faz parte da lista" << endl;
  94.  
  95. else
  96. {
  97. while(vetbuscar[i] != '\0')
  98. {
  99. if((vetbuscar[i]) == (p->Ptbr[i]) || (vetbuscar[i]) == (p->Eng[i]))
  100. i++;
  101.  
  102. else
  103. Buscar(p->next, vetbuscar);
  104.  
  105. }
  106. }
  107.  
  108. if(i==j)
  109. cout << "A palavra faz parte da lista" << endl;
  110.  
  111.  
  112. }
  113.  
  114. //===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement