Răspuns :
Răspuns:
Ti le dau pe rand
Pb 1
#include <iostream>
using namespace std;
int main()
{
int n;
cin>>n;
while(n)
{
cout<<n%10<<" ";
n/=10;
}
return 0;
}
Pb 2
#include <iostream>
using namespace std;
bool prim(int n)
{
int d;
if(n<2)
return false;
if(n==2)
return true;
for(d=2;d<=n/2;d++)
if(n%d==0)
return false;
return true;
}
int main()
{
int x,y,nr=0;
cin>>x;
y=x;
while(y!=0)
{
if(prim(y))
nr++;
cin>>x;
y=x;
}
cout<<nr;
return 0;
}
Pb 3
#include <iostream>
using namespace std;
int div(int n)
{
int nr=0;
for(int i=1;i<=n;i++)
if(n%i==0)
nr++;
if(nr==0)
return 0;
if(nr%2==0)
return 1;
return 0;
}
int main()
{
int x,y,ma=0;nr=0;
cin>>x;
y=x;
while(y!=0)
{
if(div(y))
{
nr++;
ma=ma+y;
}
cin>>x;
y=x;
}
cout<<ma/nr;
return 0;
}
Pb 4
#include <iostream>
using namespace std;
int main()
{
int n,s,y;
cin>>n;
s=n;
while(s>9)
{
int d=0;
y=s;
while(y)
{
d=d+y%10;
y/=10;
}
s=d;
}
cout<<s;
return 0;
}
Pb 5
#include <iostream>
using namespace std;
int main()
{
int n;
cin>>n;
for(int i=2;i<=n/2;i++)
if(n%i==0)
cout<<i<<" ";
return 0;
}
Pb 6
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("date.in");
bool palindrom(int n)
{
int inv=0,y=n;
if(n<10)
return true;
while(y)
{
inv=inv*10+y%10;
y/=10;
}
if(inv==n)
return true;
return false;
}
int main()
{
int x,y;
f>>x;
y=x;
while(y!=0)
{
if(palindrom(y))
cout<<y<<" ";
f>>x;
y=x;
}
return 0;
}
Pentru celelalte 2 imi dai coroana
Explicație: