Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "pch.h"
- #include <iostream>
- #include <string>
- using namespace std;
- struct Racunalnik {
- string ime;
- float takt;
- Racunalnik *next;
- } *zacetek, *konec;
- void dodajNaZacetek(Racunalnik *neki) {
- if (zacetek == NULL) {
- zacetek = neki;
- neki->next = NULL;
- konec = zacetek;
- }
- else {
- neki->next = zacetek;
- zacetek = neki;
- }
- }
- void vpis(Racunalnik *neki) {
- cin >> neki->ime;
- dodajNaZacetek(neki);
- }
- void izpis(Racunalnik *racunalnik) {
- cout << racunalnik->ime << endl;
- // cout << racunalnik->ime << " " << racunalnik->takt << endl;
- }
- void dodajNaKonec(Racunalnik *neki) {
- if (konec == NULL) {
- zacetek = neki;
- neki->next = NULL;
- konec = zacetek;
- }
- else {
- neki->next = NULL;
- konec->next = neki;
- konec = neki;
- }
- }
- void izpisSeznama() {
- for (Racunalnik *tmp = zacetek; tmp != NULL; tmp = tmp->next)
- cout << tmp->ime << " ";
- }
- int main()
- {
- zacetek = new Racunalnik;
- konec = new Racunalnik;
- zacetek = NULL;
- konec = NULL;
- Racunalnik *a = new Racunalnik;
- Racunalnik *b = new Racunalnik;
- Racunalnik *c = new Racunalnik;
- Racunalnik *d = new Racunalnik;
- vpis(a);
- vpis(b);
- vpis(c);
- vpis(d);
- cout << endl;
- izpis(a);
- cout << endl << "----------" << endl;
- dodajNaZacetek(a);
- dodajNaZacetek(c);
- dodajNaKonec(d);
- dodajNaKonec(b);
- izpisSeznama();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement