Advertisement
Guest User

Untitled

a guest
Jan 28th, 2015
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <cstdlib>
  4. #include <cmath>
  5. #include <ctime>
  6.  
  7. using namespace std;
  8.  
  9. struct LISTA
  10. {
  11. char nazwa;
  12. double wartosc;
  13. LISTA *next;
  14. };
  15.  
  16. LISTA *MAKELIST ()
  17. {
  18. LISTA *start;
  19. LISTA *aktualne;
  20.  
  21. start = NULL;
  22. aktualne = NULL;
  23.  
  24. cout << "Tworzy liste do wprowadzenie komendy 'Q'." << endl;
  25. char znak;
  26. cin >> znak;
  27. double wprowadzonawartosc;
  28.  
  29. while (znak != 'Q')
  30. {
  31. aktualne = new LISTA;
  32. aktualne->nazwa = znak;
  33. cin >> wprowadzonawartosc;
  34. aktualne->wartosc = wprowadzonawartosc;
  35. aktualne->next = start;
  36. start = aktualne;
  37. cin >> znak;
  38. }
  39.  
  40. return start;
  41. }
  42.  
  43. void PRINTLIST (LISTA *adres)
  44. {
  45. while (adres != NULL)
  46. {
  47. cout << adres->nazwa << "[" << adres->wartosc << "]" << endl;
  48. adres->next = adres;
  49. }
  50. }
  51.  
  52. void DELETELIST (LISTA *adres)
  53. {
  54. LISTA *pomocnicza;
  55.  
  56. while (pomocnicza != NULL)
  57. {
  58. pomocnicza = adres;
  59. adres->next = adres;
  60. delete pomocnicza;
  61. }
  62. }
  63.  
  64. int main()
  65. {
  66. LISTA *matrix;
  67. matrix = MAKELIST();
  68. PRINTLIST(matrix);
  69. DELETELIST(matrix);
  70. return 0;
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement