Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- struct nod{
- int info;
- nod *urm;
- };
- void ad_inc(nod *& p, int nr);
- void afisare (nod *p);
- int main()
- {
- nod *prim = NULL;
- int n, nr;
- cin >> n;
- for (int i = 1; i <= n; i++)
- {
- cin >> nr;
- ad_inc(prim, nr);
- }
- afisare(prim);
- return 0;
- }
- void ad_inc(nod *& p, int nr)
- {
- if (!p) //lista e vida
- {
- p = new nod;
- p -> info = x;
- p -> urm = NULL;
- }
- else
- {
- nod *nou = new nod;
- nou -> info = x;
- nou -> urm = p;
- p = nou;
- }
- }
- void afisare (nod *p);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement