Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- struct nod
- {
- int info;
- nod *leg;
- };
- int n;
- nod *creare ()
- {
- nod *prim, *p, *q, *n;
- prim = new nod;
- cin >> prim->info;
- q=prim;
- while (q -> info != 0)
- {
- p = new nod;
- cin >> p-> info;
- q->leg=p;
- n = q;
- q=p;
- }
- n -> leg = NULL;
- return prim;
- }
- void parcurgere(nod *prim)
- {
- nod *p;
- p = prim;
- while (p)
- {
- cout << p -> info << " ";
- p = p -> leg;
- }
- }
- int main()
- {
- int k;
- nod *prim;
- prim = creare();
- for(nod *p = prim; p != NULL; p = p -> leg)
- {
- n++;
- }
- cout << "Pe ce pozitie se face inserarea?";
- cin >> k;
- cin p -> inf;
- inserare (prim, k, inf);
- parcurgere(prim);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement