Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- ifstream fin("date.in");
- ofstream fout("date.out");
- struct nod{
- int inf;
- nod *urm,*ant;
- };
- void adaugare(nod *&ultim,nod *&prim,int x)
- {
- nod *p=new nod;
- p->inf=x;
- p->urm=NULL;
- if(prim==NULL)
- {
- p->ant=NULL;
- prim=ultim=p;
- }
- else
- {
- p->ant=ultim;
- ultim->urm=p;
- ultim=p;
- }
- }
- void creare(nod *&prim,nod *&ultim)
- {
- int x;
- prim=NULL;
- while(fin>>x)
- adaugare(ultim,prim,x);
- }
- void afisare(nod *p)
- {
- while(p!=NULL)
- {
- fout<<p->inf<<" ";
- p=p->urm;
- }
- }
- int main()
- {
- nod *prim,*ultim;
- creare(prim,ultim);
- afisare(prim);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement