Răspuns:
6.
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int a,b,s=0;cin>>a>>b;
if (a>b)
{
a=a+b;
b=a-b;
a=a-b;
}
for (int i=a;i<=b;i++)
{
for (int j=2;j<=sqrt(i);j++)
if (i%j==0)
s++;
}
cout<<s;
return 0;
}
7.
#include <iostream>
using namespace std;
int main()
{
int n,a;cin>>n;
for (int i=1;i<=n;i++)
{
int s=0;
cin>>a;
int ca=a;
while (ca)
{
s=s+ca%10;
ca/=10;
}
if (ca<=n)
cout<<a<<' ';
}
return 0;
}
8.
#include <iostream>
using namespace std;
int main()
{
int n;cin>>n;
int a=n%10;
int x=0,y=0;
n/=10;
while (n)
{
if (n%10<a) x--;
else x=101;
if (n%10>a) y--;
else y=101;
}
if (x>0&&y>0)
cout<<"cifrele nu sunt ordonate";
else
if (x<0)
cout<<"cifrele sunt ordonate descrescator";
else
if (y<0)
cout<<"cifrele sunt ordonate crescator";
return 0;
}