Varianta 85 / Subiectul 2 / Problema 5 |
#include<fstream.h> #include<math.h> ifstream f("date.in"); ofstream g("date.out"); struct nod{int info; nod *leg; }; nod *prim; void adaugf(nod *&prim,int x) {nod *nou=new nod; nou->info=x; nou->leg=prim; prim=nou; } void creare() {int x; while(f>>x) adaugf(prim,x); } void afis(nod *prim) {nod *p=prim; while(p) {g<<p->info<<" "; p=p->leg; } g<<endl; } void main() {creare(); afis(prim); nod *p=prim; while(p) { if(sqrt(p->info)==floor(sqrt(p->info))) cout<<p->info<<" "; p=p->leg; } } |