You are on page 1of 2

#include <iostream> #include <fstream> using namespace std; int v[20], n; void citire() { ifstream f("Atestat.

in"); f>>n; int i; for(i=1; i<=n; i++) f>>v[i]; } int palindrom(int x) { int y, og; y = x; og = 0; while(y>0) { og = og*10 + y%10; y = y/10; } if(x == og) return 1; else return 0; } void pcta() { int i, k = 0; // k palindroame for(i = 1; i<=n; i++) if(palindrom(v[i])==1) { cout<<v[i]<<" "; k ++; } cout<<endl; if(k == 0) cout<<"Nu exista palindroame."<<endl; } int divizor(int x) { int d, k = 0; for(d = 2; d<=x/2; d++) if(x%d == 0) k++; return k; } void pctb() { int i; for(i = 1; i<=n; i++) cout<<divizor(v[i])<<" "; cout<<endl;

} void pctc() { ofstream g("Atestat.out"); int i, k = 0; // k nr impare for(i = 1; i<=n; i++) if(v[i]%2!=0) { g<<v[i]<<" "; k ++; } if(k == 0) g<<"Nu exista numere impare in sir. "; } int main() { citire(); pcta(); pctb(); pctc(); return 0; }

You might also like