Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <cstdlib>
- #include <cmath>
- #include <ctime>
- using namespace std;
- struct LISTA
- {
- char nazwa;
- double wartosc;
- LISTA *next;
- };
- LISTA *MAKELIST ()
- {
- LISTA *start;
- LISTA *aktualne;
- start = NULL;
- aktualne = NULL;
- cout << "Tworzy liste do wprowadzenie komendy 'Q'." << endl;
- char znak;
- cin >> znak;
- double wprowadzonawartosc;
- while (znak != 'Q')
- {
- aktualne = new LISTA;
- aktualne->nazwa = znak;
- cin >> wprowadzonawartosc;
- aktualne->wartosc = wprowadzonawartosc;
- aktualne->next = start;
- start = aktualne;
- cin >> znak;
- }
- return start;
- }
- void PRINTLIST (LISTA *adres)
- {
- while (adres != NULL)
- {
- cout << adres->nazwa << "[" << adres->wartosc << "]" << endl;
- adres->next = adres;
- }
- }
- void DELETELIST (LISTA *adres)
- {
- LISTA *pomocnicza;
- while (pomocnicza != NULL)
- {
- pomocnicza = adres;
- adres->next = adres;
- delete pomocnicza;
- }
- }
- int main()
- {
- LISTA *matrix;
- matrix = MAKELIST();
- PRINTLIST(matrix);
- DELETELIST(matrix);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement