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 = NULL;
- };
- void vpis(Racunalnik *racunalnik) {
- cin >> racunalnik->ime;
- // cin >> racunalnik->takt;
- }
- void izpis(Racunalnik *racunalnik) {
- cout << racunalnik->ime << endl;
- // cout << racunalnik->ime << " " << racunalnik->takt << endl;
- }
- void dodajNaZacetek(Racunalnik *racunalnik, Racunalnik *zacetek) {
- zacetek->next = racunalnik;
- racunalnik = zacetek;
- }
- void dodajNaKonec(Racunalnik *&racunalnik, Racunalnik *konec) {
- while (racunalnik->next != NULL) {
- racunalnik = racunalnik->next;
- racunalnik->next = konec;
- }
- }
- void izpisSeznama(Racunalnik *racunalnik) {
- while (racunalnik != NULL) {
- cout << racunalnik->ime << endl;
- // cout << racunalnik->ime << " " << racunalnik->takt << endl;
- racunalnik = racunalnik->next;
- }
- }
- int main()
- {
- 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);
- izpis(b);
- izpis(c);
- izpis(d);
- cout << endl << "----------" << endl;
- dodajNaZacetek(a, b);
- dodajNaZacetek(c, a);
- dodajNaKonec(b, d);
- izpisSeznama(b);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement