Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //construiti o lista cu toate nr din fisierul date.in si sa se afiseze pe ecran numerele prime din lista creata.
- #include <iostream>
- #include <fstream>
- using namespace std;
- ifstream f("date.in");
- struct nod
- {
- int info;
- nod *adr;
- };
- nod *prim;
- int prim()
- void creare()
- {
- nod *p,*nou;
- while (f>>x)
- if (prim==NULL)
- {
- prim=new nod;
- prim->info=x;
- p=prim;
- }
- else
- {
- nou=new nod;
- nou->info=x;
- p->adr=nou;
- p=nou;
- }
- p->adr=NULL;
- }
- void parcurgere()
- {
- nod *p=prim;
- while (p)
- {cout<<p->info<<" ";
- p=p->adr;
- }
- }
- int main()
- {
- creare();
- parcurgere;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement