Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- struct Nod
- {
- int info;
- Nod *st, *dr;
- };
- Nod *L, *U;
- void Creare (int x)
- {
- L = new Nod;
- U = L;
- L -> st = L -> dr = NULL;
- l -> info = x;
- }
- void InsInainte (Nod *p, int x)
- {
- Nod *q = new Nod;
- q -> info = x;
- q -> dr = p;
- q -> st = p -> st;
- p -> st -> dr = q;
- p -> st = q;
- }
- void InsInceput (int x)
- {
- Nod *p = new Nod;
- p -> info = x;
- p -> dr = L;
- p -> st = NULL;
- L -> st = p;
- L = p;
- }
- void ParcSD ()
- {
- for (Nod *p = L; p != NULL; p = p -> dr)
- cout << p -> info << " ";
- cout << "\n";
- }
- int main()
- {
- int n;
- cin >> n;
- cin >> x;
- Creare(x);
- for (i = 2; i <= n; i++)
- InsInainte()
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement