Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include<fstream>
- #include<cstring>
- using namespace std;
- ifstream f("date.in");
- struct nod
- {
- int info;
- nod *urm;
- };
- nod *prim;
- void creare()
- {
- nod *p,*nou;
- int x,i;
- f>>x;
- for (i=0;i<=x;i+=2)
- {
- if(prim==NULL && (i%2)==0)
- {
- prim=new nod;
- prim->info=i;
- p=prim;
- }
- else
- if(i%2==0)
- {
- nou=new nod;
- nou->info=i;
- p->urm=nou;
- p=nou;
- }
- p->urm=NULL;
- }
- }
- void afisare ()
- {
- nod *p=prim;
- while (p)
- {
- cout<<p->info<<" ";
- p=p->urm;
- }
- }
- int main()
- { creare();
- afisare();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement