You are on page 1of 11

#include <iostream>

#include <fstream>
using namespace std;
int numarcifrepare(int x)
{ int c=0;
while(x>0)
{
if(x%2==0)
{x=x/10;
c++;}
else {x=x/10;}
} return c;}
int main()
{
int n,p,k,x;
ifstream f("atestat.in");
ofstream o("atestat.out");
f>>n>>p>>k;
int v[30],a[30];
for(int i=1;i<=n;i++)
{
f>>x;
a[i]=x;
if(x%p==k)
{
cout<<x<<" ";
}
v[i]=numarcifrepare(x);
}
cout<<endl;
for(int i=1;i<=n;i++)
{
cout<<v[i]<<" ";}
int c=0;
for(int i=1;i<=(n-1);i++)
for(int j=(i+1);j<=n;j++)
if(a[i]==a[j])
c++;
if(c==0)
{
o<<"ELEMENTELE SUNT DISTINCTE";
} else o<<"ELEMENTELE NU SUNT DISTINCTE";
return 0;
}

#include <iostream>
#include <fstream>
#include <Cmath>
using namespace std;
int elemmin(int v[30],int n)
{
int minn=11,pm;
for(int i=1;i<=n;i++)
{
if(v[i]<minn)
{minn=v[i];
pm=i;}
}
return pm;
}
int main()
{
ifstream f("atestat.in");
ofstream o("atestat.out");
int v[30],a[30],n,c,z;
f>>n;
for(int i=1;i<=n;i++)
{
f>>v[i];
z=v[i];
a[i]=(z/10)%10;
cout<<(z/10)%10<<" ";
}
cout<<endl<<elemmin(a,n);
for(int i=1;i<=n;i++)
{
if(v[i]>=100 && v[i]<=999)
{
c=0;
for(int j=2;j<=sqrt(v[i]);j++)
{if(v[i]%j==0)c++;}
if(c==0) o<<v[i]<<" ";
}
}
return 0;
}

#include <iostream>
#include <fstream>
#include <Cmath>
using namespace std;
int descrescator(int v[30],int n)
{
for(int i=2;i<=n;i++)
{
if(v[i-1]<v[i]) return 0; }
return 1;
}
int main()
{
ifstream f("atestat.in");
ofstream o("atestat.out");
int n,x,y,z,c,sumadiv;
f>>n;
int v[50];
for(int i=1;i<=n;i++)
{
f>>v[i];
sumadiv=0;
for(int j=1;j<=sqrt(v[i]);j++)
{
if(v[i]%j==0)
{
sumadiv=sumadiv+j;
sumadiv=sumadiv+(v[i]/j);
}
}
cout<<sumadiv<<" ";
}

//a

if(descrescator(v,n)==0) cout<<endl<<"NU";
else cout<<endl<<"DA";
for(int i=2;i<=n;i++)
{
if(v[i-1]==2*v[i])
{
o<<v[i-1]<<" "<<v[i]<<endl;
}
}
return 0;}

#include <iostream>
#include <fstream>
#include <Cmath>
using namespace std;
int descrescator(int v[30],int n)
{
for(int i=2;i<=n;i++)
{
if(v[i-1]<v[i]) return 0;
}
return 1;
}
int cifracontrol(int x)
{
int sumacifre=0;
while(x>0)
{sumacifre=sumacifre+(x%10);
x=x/10;}
if(sumacifre>10)
{
sumacifre=sumacifre%10+(sumacifre/10)%10;
}
if(sumacifre>10) sumacifre=sumacifre%10+(sumacifre/10)%10;
return sumacifre;
}
int main()
{
ifstream f("atestat.in");
ofstream o("atestat.out");
int n,x,y,z,c,sumadiv;
f>>n;
int v[50];
for(int i=1;i<=n;i++)
{
f>>v[i];
sumadiv=0;
for(int j=1;j<=sqrt(v[i]);j++)
{
if(v[i]%j==0)

//a

{
sumadiv=sumadiv+j;
sumadiv=sumadiv+(v[i]/j);
}
}
cout<<sumadiv<<" ";
}
if(descrescator(v,n)==0) cout<<endl<<"NU";
else cout<<endl<<"DA";
for(int i=2;i<=n;i++)
{
if(v[i-1]==2*v[i])
{
o<<v[i-1]<<" "<<v[i]<<endl;
}
}
return 0;
}

#include <iostream>
#include <fstream>
using namespace std;
int maxx(int v[30],int n)
{ int maxim=0;
for(int i=1;i<=n;i++)
{ if(maxim<=v[i])
maxim=v[i] }
return maxim;}
int sumacifre(int v[30],int n)
{ int a=maxx(v,n);
int suma=0;
while(a>0)
{suma=a%10+suma;
a=a/10; }
return suma;}
int main()
{ ifstream f("atestat.in");
ofstream o("atestat.out");
int n,v[30];
f>>n;
for(int i=1;i<=n;i++)
{ f>>v[i];
if(v[i]%3==0 && v[i]%2==1)
cout<<v[i]<<" "; }
cout<<endl<<sumacifre(v,n);
int cpy,c;
bool s=true;
for(int i=1;i<=n;i++)
{ cpy=v[i];c=cpy%10;cpy=cpy/10;
while(cpy>0)
{
if(cpy%10<c)
{
c=cpy%10;
cpy=cpy/10;
} else{s=false; break;}
}
if(s==true)
{ o<<v[i]<<" "; } }
return 0;}

#include <iostream>
#include <fstream>
using namespace std;
int rast(int x)
{
int invers;
while(x!=0)
{
invers=invers*10+x%10;
x=x/10;
}
return invers;
}
int main()
{ ifstream f("atestat.in");
ofstream g("atestat.out");
int n,a,c,v[100];
f>>n>>c;
for(int i=1;i<=n;i++)
{
f>>a;
v[i]=a;
if(a%10==c)
{
cout<<v[i]<<" ";
}
}
cout<<endl;
for(int i=1;i<=n;i++)
{
if(v[i]%2==1)
cout<<rast(v[i])<<" ";
} c=0;
for(int i=1;i<=n;i++)
{
if(v[i]>100 && v[i]<999)
if(v[i]==rast(v[i]))
{ g<<v[i]<<" ";
c++;
}
} if(c==0)
{ g<<"NU EXISTA NUMERE PALINDROM DE TREI CIFRE"; }
return 0;}

#include <iostream>
#include <fstream>
using namespace std;
int cifre (int x)
{ int uc,pc;
pc=x%10;
while(x>=0)
{
uc=x%10;
x=x/10;
//b
}
if(uc==pc)
{
return 1;
} else return 0;
}
int main()
{
ifstream s("atestat.in");
ofstream o("atestat.out");
int n,i=1, v[100];
while(s>>v[i])
{
s>>v[i];
if(v[i]%2==0 && i%2==1)
{
cout<<v[i]<<" ";
//a
}
i++;
}
n=i;int minn=0,maxx=0;
for(i=1;i<=n;i++)
{ if(minn>=v[i])minn=v[i];
if(maxx<=v[i])maxx=v[i];
if(cifre(v[i])==1)cout<<v[i];
}
float ma=(minn+maxx)/2;
//c
o<<ma;
return 0;
}

#include <iostream>
#include <fstream>
#include <cmath>
int ndiv(int x)
{
int i,nr;
for(i=2;i<=sqrt(x);i++)
{
if(x%i==0)
{
nr++;
}
}
return nr;
}
int main()
{
ifstream s("atestat.in");
ofstream o("atestat.out");
int n,v[100],maxx=0,frec[10],c;
s>>n;
for(int i=1;i<=10;i++)frec[i]=0;
for(int i=1;i<=i;i++)
{s>>v[i];
c=v[i];
while (c>=0)
{frec[c%10]=frec[c%10] + 1;
c=c/10;}
}
for(int i=1;i<=10;i++)
{
if(frec[i]>maxx)
maxx=frec[i];
}
cout<<maxx<<endl;
for(int i=1;i<=n;i++)
{if(ndiv(v[i])>=maxx)
maxx=ndiv(v[i]);
if(ndiv(v[i])==0)o<<v[i]<<" ";
}
cout<<maxx;
return 0;
}

#include <iostream>
#include <fstream>
#include <cmath>
int egal(int x)
{
int cp=0,ci=0;
while(x>=0)
{
if(x%2==0)
{
cp++;
}else ci++;
}
if(ci==cp)
{
return 1;
} else return 0;
}
int main()
{
ifstream s("atestat.in");
ofstream o("atestat.out");
int n,v[20],minn,pozmin;
s>>n;
for(int i=1;i<=n;i++)
{
s>>v[i];
if(v[i]%5==0)
{
cout<<v[i]<<" ";
}
}
cout<<endl;
minn=v[1];
pozmin=1;
for(int i=1;i<=n;i++)
{
cout<<egal(v[i])<<" ";
if(minn>=v[i]){minn=v[i];pozmin=i;}
}
o<<minn<<" "<<pozmin;
return 0;
}

#include <iostream>
#include <fstream>

#include <cmath>

void sortt(float x[100],int n)


{ int maxx=0;
for(int i=1;i<=n;i++)
maxx=0;
for(int j=1;j<=n;j++)
if(maxx<=x[j]){ maxx=x[j];x[j]=0;}
cout<<maxx;
}
int main()
{
ifstream s("atestat.in");
ofstream o("atestat.out");
float v[100],suma;
int n,c=0;;
s>>n;
for(int i=1;i<=n;i++)
{
s>>v[i];
if(v[i]<=10.0)
{
cout<<(v[i]/1.0);
suma=suma+v[i];c++;
}
}
sortt(v,n);
o<<(suma/c);
return 0;
}