Sunteți pe pagina 1din 107

LICEULTEORETICSOLOMONHALITA

PROBLEMEDE
INFORMATICA
REZOLVATE
ALGORITMSIPROGRAMC++
CLASAaIXa

2011

1.EcuatiadegradulI
Algoritm:
start
citestea,b
dacaa=0atunci
dacab=0atunci
tipareste"xoricenumarreal"
altfel
tipareste"ecuatieimposibila"
sfarsitdaca
altfel
tipareste"x="b/a
sfarsitdaca
stop
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
inta,b;
intmain()
{
cout<<"a=";cin>>a;
cout<<"b=";cin>>b;
if(a==0)
if(b==0)
cout<<"xoricenumarreal";
else
cout<<"ecuatieimposibla";
else
cout<<"x="<<b/a;
getch();
return0;}
2.EcuatiadegradulII
Algoritm:
start
citestea,b,c
dacaa=0atunci
dacab=0atunci
dacac=0atunci
tipareste"x1,x2oricenumarreal"
altfel
tipareste"ecuatieimposibila"
sfarsitdaca
altfel
tipareste"x="c/b
sfarsitdaca
altfel
Delta=b*b4ac
dacaDelta>=0atunci
x1=(b+radical(Delta))/2a
x2=(bradical(Delta))/2a

tipareste"x1="x1"x2="x2
altfel
tipareste"nuavemsolutiireale"
sfarsitdaca
sfarsitdaca
stop
Program:
#include<iostream>
#include<conio.h>
#include<math.h>
usingnamespacestd;
inta,b,c;
floatx1,x2,D;
intmain()
{
cout<<"a=";cin>>a;
cout<<"b=";cin>>b;
cout<<"c=";cin>>c;
if(a==0)
if(b==0)
if(c==0)
cout<<"a=0b=0c=0=>0=0=>x1,x2oricenumerereale"<<endl;
else
cout<<"a=0b=0cdiferitde0=>c=0=>ecuatieimposibila"<<endl;
else
cout<<"a=0=>bx+c=0=>ecuatiedegrad1=>solutia=b/c=xx="<<b/a<<endl;
else
{
cout<<"toatenumerelesuntnenule=>secalculeazadeltadupaformulaD=(b*b)(4*a*c)"<<endl;
D=(b*b)(4*a*c);
if(D>0)
{
cout<<"deltaestemaimaredecatzero=>calculampex1six2dupaformulele:x1=(bradicaldin
D)/(2*a)six2=(b+radicaldinD)/(2*a)"<<endl;
x2=(b+sqrt(D))/(2*a);
x1=(bsqrt(D))/(2*a);
cout<<"x1="<<x1<<""<<"x2="<<x2<<endl;
}
else
cout<<"Deltaestenegativ=>ecuatieimposibila"<<endl;
getch();
return0;}
}
3.Secitesc4intreginumeresasedeterminedacaexistaprintreele3numerepozitive.
Algoritm:
start
citestea,b,c,d
daca((a>0sib>0sic>0)sau(a>0sib>0sid>0)sau(a>0sic>0sid>0)sau(b>0sic>0sid>0))
tipareste"avemtreinumerepozitive"
altfel
tipareste"nuavemtreinumerepozitive"

sfarsitdaca
stop
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
longa,b,c,d;
intmain()
{
cout<<"a=";cin>>a;
cout<<"b=";cin>>b;
cout<<"c=";cin>>c;
cout<<"d=";cin>>d;
if((a>0&&b>0&&c>0)||(a>0&&b>0&&d>0)||(a>0&&c>0&&d>0)||(b>0&&c>0&&d>0))
cout<<"avemtreinumerepozitive";
else
cout<<"nuavemtreinumerepozitive";
getch();
return0;
}
4.Secitesteunnumarpozitiv,intreg,demaxim5cifresasedeterminecatecifrearenumarul
Algoritm:
start
citesten
dacan<10atunci
tipareste"areocifra"
altfel
dacan<100atunci
tipareste"are2cifre"
altfel
dacan<1000atunci
tipareste"are3cifre"
altfel
dacan<10000atunci
tipareste"are4cifre"
altfel
dacan<100000atunci
tipareste"are5cifre"
altfel
tipareste"nurespectaconditia"
sfarsitdaca
sfarsitdaca
sfarsitdaca
sfarsitdaca
sfarsitdaca
stop
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
longn;

intmain()
{
cout<<"n=";cin>>n;
if(n<10)
cout<<"areocifra";
else
if(n<100)
cout<<"are2cifre";
else
if(n<1000)
cout<<"are3cifre";
else
if(n<10000)
cout<<"are4cifre";
else
if(n<100000)
cout<<"are5cifre";
else
cout<<"nurespectaconditia";
getch();}
5.Secitesc3nr.Sasedet.careestemaimare.
Algoritm:
start
citestea,b,c,
dacaa>b,atunci
dacaa>c,atunci
tiparestea
altfel
tiparestec
sf.daca
dacab>c,atunci
tiparesteb
altfel
tiparestec
sf.daca
sf.daca
stop
Program:
#include<iostream>

#include<conio.h>
usingnamespacestd;
inta,b,c;
intmain(){
cout<<"a=";cin>>a;
cout<<"b=";cin>>b;
cout<<"c=";cin>>c;
if(a>b)
if(a>c)
cout<<"nrmaimareeste"<<a;
else
cout<<"nrmaimareeste"<<c;
else
if(b>c)
cout<<"nrmaimareeste"<<b;
else
cout<<"nrmaimareeste"<<c;
getch();
return0;}
6.Secitesc4nr.Sasedet.dacaexista3nracarorsumasafiepozitiva.
Algoritm:
start
citestea,b,c,d
dacaa+b+c>0saua+b+d>0saub+c+d>0,atunci
tipareste"sumaestepozitiva"
altfel
tipareste"sumanuestepozitiva"
sf.daca
stop
Program:
#include<iostream>
#include<conio.h>

usingnamespacestd;
inta,b,c,d;
intmain(){
cout<<"a=";cin>>a;
cout<<"b=";cin>>b;
cout<<"c=";cin>>c;
cout<<"d=";cin>>d;
if((a+b+c>0)||(a+b+d>0)||(b+c+d>0))
cout<<"sumaestepozitiva";
else
cout<<"sumanuestepozitiva";
getch();
return0;}
7.Secitesc4nr.Sasedet.dacaexista3nr.acarorprodussafiepozitiv.
Algoritm:
start
citestea,b,c,d
dacaa*b*c>o,saua*b*d>0,saub*c*d>0,atunci
tipareste"produsulestepozitiv"
altfel
tipareste"produsulnuestepozitiv"
sf.daca
stop
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
inta,b,c,d;
intmain(){
cout<<"a=";cin>>a;
cout<<"b=";cin>>b;
cout<<"c=";cin>>c;

cout<<"d=";cin>>d;
if((a*b*c>0)||(a*c*d>0)||(b*c*d))
cout<<"produsulestepozitiv";
else
cout<<"produsulnuestepozitiv";
getch();
return0;}
8.Secitesc4nr.Sasedet.dacasunt3pozitive.
Algoritm:
start
citestea,b,c,d
daca((a>0sib>0sic>0)sau(a>bsib>0sid>0)sau(a>0sic>csid>0)sau(b>0sic>0sid>0))
tipareste"sunttreinrpozitive"
altfel
tipareste"nusunttreinrpozitive"
sf.daca
stop
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
inta,b,c,d;
intmain(){
cout<<"a=";cin>>a;
cout<<"b=";cin>>b;
cout<<"c=";cin>>c;
cout<<"d=";cin>>d;
if((a>0&&b>0&&c>0)||(a>0&&b>0&&d>0)||(a>0&&c>0&&d>0)||(b>0&&c>0&&d>0))
cout<<"sunttreinr.pozitive";
else
cout<<"nusunttreinr.pozitive";
getch();

return0;}
9.Sasescrieunalgoritmcareciteste3numerelesideterminadacaceletreinumerepotreprezenta
laturileunuitriunghi.Incazafirmativsasedeterminetipultrunghiului,perimetrulsiariaacestuia.
Algoritm:
Start
Citestea,b,c
Dacaa>0sib>osic>0sia+b>csia+c>bsib+c>aatunci
Tiparestepotreprezentalaturileunuitriunghi
Dacaa=bsia=catunci
Tiparestetriunghiechilateral
Altfel
Dacaa=bsaua=csaub=catunci
Tiparesteisoscel
Sfarsitdaca
Dacaa*a=b*b+c*csaub*b=a*ac*csauc*c=a*a+b*batunci
Tiparestedreptunghic
Sfarsitdaca
Dacaa=bsia=csib==csia*a+b*b=c*csib*b+c*c=a*aatunci
Tiparesteoarecare
Sfarsitdaca
Sfarsitdaca
P=a+b+c
Tiparesteperimetruleste,P
R=P/2
A=p(pa)(pb)(pc)
Tiparesteariaeste,A
Sfarsitdaca
Stop
Program:
#include<iostream>

#include<conio.h>
usingnamespacestd;
inta,b,c;
floutA,P;
intmain();{
cout<<"a=";cin>>a;
cout<<"b=";cin>>b;
cout<<"c=";cin>>c;
if(a>0&&b>0&&c>0&&a+b>c&&b+c>a&&a+c>b)
{cout<<"potreprezentalaturileunuitringhi";
if(a==b&&a==c)
cout<<"triunghiulesteechilateral";
else
if(a==b||a==c||b==c)
cout<<"triunghiulesteisoscel";
else
if(a*a+b*b==c*c||a*a+c*c==b*b||b*b+c*c==a*a)
cout<<"triunghiulestedreptunghic";
else
cout<<"triunghiulesteoarecare";
P=a+b+c;
cout<<"perimetruleste"<<P;
P=P/2;
A=sqrt(P*(Pa)*(Pb)*(Pc));
cout<<"ariaeste"<<A;}
else
cout<<"nupotreprezentalaturileunutriunghi";
getch();
return0;}
10.Secitesctreinumeresasedeterminedacaelepotreprezentacaunghiurialeunuitriunghi.

Algoritm:
Start
Citestea,b,c
Dacaa>0sib>0sic>0sia+b+c=180atunci
Tiparestepotreprezentaunghiurileunuitriunghi
Dacaa=bsia=catunci
Tiparesteechilateral
Altfel
Daca(a=bsaub=csaua=c)si(a=90saub=90sauc=90)atunci
Tiparesteisosceldreptunghic
Altfel
Dacaa=bsaub=csaua=catunci
Tiparesteisoscel
Altfel
Dacaa=90saub=90sauc=90atunci
Tiparestedreptunghic
Altfel
Tiparesteoarecare
Sfarsitdaca
Sfarsitdaca
Sfarsitdaca
Sfarsitdaca
Sfarsitdaca
Altfel
Tiparestenupotreprezentaunghiurileunuitriunghi
Sfarsitdaca
Stop
Program:
#include<iostream>
#include<conio.h>

usingnamespacestd;
inta,b,c;
intmain();{
cout<<"a=";cin>>a;
cout<<"b=";cin>>b;
cout<"c=";cin>>c;
if(a>0&&b>0&&c>0&&a++c==180)
cout<<"potreprezentaunghiurileunuitriunghi";
if(a==b&&a==c)
cout<<"triunghiulechilateral";
else
if(a==b||b==c||a==c)
cout<<"triunghiulesteisoscel";
else
if(a==90||b==90||c==90)
cout<<"triunghiulestedreptunghic";
else
cout<<"triunghiulesteoarecare";
else
cout<<"triunghiulesteoarecare";}
else
cout<<"nupotreprezentaunghiurileunuitriunghi";
getch();
return0;}
11.Sedaupatrunumeresasedeterminedacaelearputeareprezentalaturileunuidreptunghi,iarin
cazafirmativsasedetermineariasiperimetrul.
Algoritm:
Start
Citestea,b,c,d
Dacaa>0sib>0sic>0sid>0sia=bsic=dsaua=csia=datunci

Tiparestepotreprezentalaturileunuidreptunghi
P=a+b+c+d
TiparesteperimetrulesteP
Dacaa!=batunci
A=a*b
Altfel
A=a*c
Sfarsitdaca
TiparesteariaesteA
Altfel
Tiparestenupotreprezentalaturileunuidreptunghi
Sfarsitdaca
Stop
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
inta,b,c,d,A,P;
intmain(){
cout<<"a=";cin>>a;
cout<<"b=";cin>>b;
cout<<"c=";cin>>c;
cout<<"d=";cin>>d;
if(a>0&&b>0&&c>0&&d>0&&a=b&&c=d||a=c&&a=datunci
cout<<"potreprezentalaturieunuidreptunghi";
P=a+b+c+d;
cout<<"perimetruleste"<<P;
ifa!=b
A=a*b
else

A=a*c
cout<<"ariaeste"<<A;
else
cout<<"nupotreprezentalaturileunuidreptunghi";
getch();
return0;}
12.Sasescrieunalgoritmcarecitestetreinumeresiafiseazanumerelecititeinrodinecrescatoare.
Algoritm:
Start
Citestea,b,c
Dacaa>batunci
Dacab>catunci
Tiparestec,b,a
Altfel
Dacaa>catunci
Tiparesteb,c,a
Altfel
Tiparesteb,a,c
Sfarsitdaca
Sfarsitdaca
Altfel
Dacab<catunci
Tiparestea,b,c
Altfel
Tiparestea,c,b
Sfarsitdaca
Altfel
Tiparestec,a,b
Sfarsitdaca
Sfarsitdaca

Stop
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
inta,b,c
intmain(){
cout<<"a=";cin>>a;
cout<<"b=";cin>>b;
cout<<"c=";cin>>c;
if(a>b)
if(b>c)
cout<<c<<","<<b<<","<<a<<endl;
else
if(a>c)
cout<<b<<","<<c<<","<<a<<endl;
else
cout<<b<<","<<a<<","<<c<<endl;
else
if(b<c)
cout<<a<<","<<b<<","<<c<<endl;
else
cout<<a<<","<<c<<","<<b<<endl;
else
cout<<c<<","<<a<<","<<b<<endl;
getch();
return0;}
13.Secitesc3numeresasedeterminedacacele3numererespectaproprietatea,teoremalui
Pitagora.
Algoritm:
Start

Citestea,b,c
Dacaa*a+b*b=c*csaua*a+c*c=b*bsaub*b+c*c=a*aatunci
Tipareste"respectateoremaluiPitagora"
Altfel
Tipareste"nurespectateoremaluiPitagora
Sfarsitdaca
Stop
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
inta,b,c;
intmain(){
cout<<"a=";cin>>a;
cout<<"b=";cin>>b;
cout<<"c=";cin>>c;
if(((a*a+b*b)==c*c)||((a*a+c*c)==b*b)||((b*b+c*c)==a*a))
cout<<"respectateoremaluiPitagora";
else
cout<<"nurespectateoremaluiPitagora";
getch();
return0;
}
14.Secitesc3numere.Sasedeterminedacacele3numereauacelasinumardecifre.Numerelepot
saaibamaxim5cifre.
Algoritm:
start
citestea,b,c
x=y=z=0
cattimpa0executa
x=x+1
a=cat(a,10)
sfarsitcattimp
cattimpb0executa
y=y+1
b=cat(b,10)
sfarsitcattimp
cattimpc0executa
z=z+1
c=cat(c,10)
sfarsitcattimp
dacax=y=z

tipareste"numereleauacelasinumardecifre"
altfel
tipareste"numerelenuauacelasinumardecifre"
sfarsitcattimp
stop
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;

inta,b,c,x,y,z;
intmain(){
cout<<"a=";cin>>a;
cout<<"b=";cin>>b;
cout<<"c=";cin>>c;
x=y=z=0;
while(a)
{x++;
a=a/10;}
while(b)
{y++;
b=b/10;}
while(c)
{z++;
c=c/10;}
if(x==y&&y==z)
cout<<"auacelasinumardecifre";
else
cout<<"nuauacelasinumardecifre";
getch();
return0;
}
15.Secitesc4numere.Saseafisezenumereleinordinecrescatoare.
Algoritm:
start
citestea,b,c,d
dacaa<b<c<datunci
tipareste"a<b<c<d"
dacaa<b<d<catunci
tipareste"a<b<d<c"
dacaa<c<b<datunci
tipareste"a<c<b<d"
dacaa<c<d<batunci
tipareste"a<c<d<b"
dacaa<d<b<catunci
tipareste"a<d<b<c"
dacaa<d<c<batunci
tipareste"a<d<c<b"
dacab<a<c<datunci
tipareste"b<a<c<d"
dacab<a<d<catunci
tipareste"b<a<d<c"
dacab<c<a<datunci
tipareste"b<c<a<d"
dacab<c<d<aatunci
tipareste"b<c<d<a"
dacab<d<a<catunci
tipareste"b<d<a<c"
dacab<d<c<aatunci
tipareste"b<d<c<a"
dacac<b<a<datunci

tipareste"c<b<d<a"
dacac<b<a<datunci
tipareste"c<a<b<d"
dacac<b<a<datunci
tipareste"c<a<d<b"
dacac<b<a<datunci
tipareste"c<a<d<b"
dacac<d<a<batunci
tipareste"c<d<a<b"
dacac<d<b<aatunci
tipareste"c<d<b<a"
dacad<a<b<catunci
tipareste"d<a<b<c"
dacad<a<c<batunci
tipareste"d<a<c<b"
dacad<b<a<catunci
tipareste"d<b<a<c"
dacad<b<c<aatunci
tipareste"d<b<c<a"
dacad<c<a<batunci
tipareste"d<c<a<b"
dacad<c<b<aatunci
tipareste"d<c<b<a"
sfarsitdaca
sfarsitdaca
sfarsitdaca
sfarsitdaca
sfarsitdaca
sfarsitdaca
sfarsitdaca
sfarsitdaca
sfarsitdaca
sfarsitdaca
sfarsitdaca
sfarsitdaca
sfarsitdaca
sfarsitdaca
sfarsitdaca
sfarsitdaca
sfarsitdaca
sfarsitdaca
sfarsitdaca
sfarsitdaca
sfarsitdaca
sfarsitdaca
sfarsitdaca
sfarsitdaca
sfarsitdaca
sfarsitdaca
sfarsitdaca
sfarsitdaca

sfarsitdaca
sfarsitdaca
sfarsitdaca
sfarsitdaca
sfarsitdaca
sfarsitdaca
sfarsitdaca
stop
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
inta,b,c,d;
intmain(){
cout<<"a=";cin>>a;
cout<<"b=";cin>>b;
cout<<"c=";cin>>c;
cout<<"d=";cin>>d;
if(a<b&&b<c&&c<d)
cout<<a<<"<"<<b<<"<"<<c<<"<"<<d;
if(a<b&&b<d&&d<c)
cout<<a<<"<"<<b<<"<"<<d<<"<"<<c;
if(a<c&&c<b&&b<d)
cout<<a<<"<"<<c<<"<"<<b<<"<"<<d;
if(a<c&&c<d&&d<b)
cout<<a<<"<"<<c<<"<"<<d<<"<"<<b;
if(a<d&&d<b&&b<c)
cout<<a<<"<"<<d<<"<"<<b<<"<"<<c;
if(b<a&&a<c&&c<d)
cout<<b<<"<"<<a<<"<"<<c<<"<"<<d;
if(b<a&&a<d&&d<c)
cout<<b<<"<"<<a<<"<"<<d<<"<"<<c;
if(b<c&&c<a&&a<d)
cout<<b<<"<"<<c<<"<"<<a<<"<"<<d;
if(b<c&&c<d&&d<a)
cout<<b<<"<"<<c<<"<"<<d<<"<"<<a;
if(b<d&&d<a&&a<c)
cout<<b<<"<"<<d<<"<"<<a<<"<"<<c;
if(b<d&&d<c&&c<a)
cout<<b<<"<"<<d<<"<"<<c<<"<"<<a;
if(c<b&&b<a&&a<d)
cout<<c<<"<"<<b<<"<"<<a<<"<"<<d;
if(c<b&&b<d&&d<a)
cout<<c<<"<"<<b<<"<"<<d<<"<"<<a;
if(c<d&&d<a&&a<b)
cout<<c<<"<"<<d<<"<"<<a<<"<"<<b;
if(c<d&&d<b&&b<a)
cout<<c<<"<"<<d<<"<"<<b<<"<"<<a;
if(d<a&&a<b&&b<c)
cout<<d<<"<"<<a<<"<"<<b<<"<"<<c;
if(d<a&&a<c&&c<b)

cout<<d<<"<"<<a<<"<"<<c<<"<"<<b;
if(d<b&&b<a&&a<c)
cout<<d<<"<"<<b<<"<"<<a<<"<"<<c;
if(d<b&&b<c&&c<a)
cout<<d<<"<"<<b<<"<"<<c<<"<"<<a;
if(d<c&&c<b&&b<a)
cout<<d<<"<"<<c<<"<"<<b<<"<"<<a;
getch();
return0;
}
16.Secitesteunnumarformatdinexact5cifresasetipareascasumacifrelornumarului.
Algoritm:
start
citestex
s=0
cattimpx0executa
s=s+rest(n,10)
x=cat(x,10)
sfarsitcattimp
tiparestes
stop
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
ints,x;
intmain(){
s=0;
cout<<x=0cin>>x;
while(x)
{s=s+n%10;
x=x/10;}
cout<<s;
getch();
return0;
}
17.Secitesteunnumar.Sasedeterminesumacifrelorparesirespectivsumacifrelorimpare.
Numarulcontinecincicifre.
Algoritm:
START
citestea
C5=rest(a,10)
C4=rest(cat(a,10),10)
C3=rest(cat(a,100),10)
C2=rest(cat(a,1000),10)
C1=rest(a,10000)
P=0
I=0
Dacarest(C1,C2)=Oatunci
P=P+C1
Altfel

I=I+C1
Sfarsitdaca
Dacarest(C2,2)=0atunci
P=P+C2
Altfel
I=I+C2
Sfarsitdaca
Dacarest(C3,2)=0atunci
P=P+C3
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
intn,p,i;
intmain(){
cout<<"n=";
cin>>n;
if(n>=10000&&n<100000)
{while(n)
{if((n%10)%2==0)
p+=n%10;
else
i+=n%10;
n=n/10;}
cout<<"sumacifrelorpareeste"<<p;
cout<<"sumacifrelorimpareeste"<<i;}
else
cout<<"nurespectaconditia";
getch();
return0;}
18.Secitescdouanumerecarecontinexactpatrucifre.Saseafisezesumacifrelordepefiecaredin
celepatrupozitiialenumerelor.
Algoritm:
START
Citestec,d
C1=cat(c,1000)
C2=rest(cat(c,100),10)
C3=rest(cat(c,10),10)
C4=rest(c,10)
D1=cat(d,1000)
D2=rest(cat(d,100),10)
D3=rest(cat(d,10),10)
D4=rest(d,10)
Tiparestepozitia1,C1+D1
Tiparestepozitia2,C2+D2
Tiparestepozitia3,C3+D3
Tiparestepozitia4,C4+D4
STOP
Program:
#include<iostream>
#include<conio.h>

usingnamespacestd;
intx,y,a;
intmain(){
cout<<"x=";cin>>x;
cout<<"y=";cin>>y;
a=1;
while(x&&y)
{cout<<"sumacifrelordepepozitia"<<a<<"este"<<x%10+y%10<<endl;
x=x/10;
y=y/10;
a++;}
getch();
return0;}
19.Secitesteunnumardeexactpatrucifre.Sasedetermineceamaimicacifraasa.
Algoritm:
START
Citestea
C1=cat(a,1000)
C2=rest(cat(a,100),10)
C3=rest(cat(a,10),10)
C4=rest(a,10)
min=C1
Dacamin>C2atunci
min=C2
Sfarsitdaca
Dacamin>C3atunci
min=C3
Sfarsitdaca
Dacamin>C4atunci
min=C4
Sfarsitdaca
Tiparestemin,estevaloareaceamaimica
STOP
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
intn,m;
intmain(){
cout<<"n=";cin>>n;
m=9;
if(n>=1000&&n<10000)
{while(n)
{if(n%10<=m)
m=n%10;
n=n/10;}
cout<<"ceamaimicacifraeste"<<m;}
else
cout<<"numarulnuarepatrucifre";
getch();
return0;}

20.Secitesteunnumarformatdinsasecifre.Sasenumerecatedintrecifrelesalesuntcuprinsein
intervalul[3,6].
Algoritm:
START
Citestea
C1=cat(a,100000)
C2=rest(cat(a,10000),10)
C3=rest(cat(a,1000),10)
C4=rest(cat(a,100),10)
C5=rest(cat(a,10),10)
C6=rest(a,10)
P=0
DacaC1>=3siC1<=6atunci
P=P+1
Sfarsitdaca
DacaC2>=3siC2<=6atunci
P=P+1
Sfarsitdaca
DacaC3>=3siC3<=6atunci
P=P+1
18.Sfarsitdaca
DacaC4>=3siC4<=6atunci
P=P+1
Sfarsitdaca
DacaC5>=3siC5<=6atunci
P=P+1
Sfarsitdaca
DacaC6>=3siC6<=6atunci
P=P+1
Sfarsitdaca
Tiparesteavem,P,cifreinintervalul[3,6]
STOP
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
intn,p;
intmain(){
cout<<"n=";cin>>n;
if(n>=100000&&n<1000000)
{while(n)
{if(n%10>=3&&n%10<=6)
p++;
n=n/10;}
cout<<"sunt"<<p<<"cifrecuprinseinintervalul[3,6]";}
else
cout<<"nurespectaconditia";
getch();
return0;}
21.Secitesteunnumarcarecontineexactpatrucifre.Saseafisezecatulsirestulimpartiriiprimului
numarformatdinprimeledouacifrealenumaruluilanumarulformatdinultimeledouacifre.

Algoritm:
Start
Citestea
C1=cat(a,100)
C2=rest(a,100)
Tiparesterestuleste,rest(C1,C2)
Stop.
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
intC1,C2,a;
intmain(){
cout<<"a=";cin>>a;
C1=a/100;
C2=a%100;
cout<<"catuleste"<<C1/C2;
cout<<"restuleste"<<C1%C2;
getch();
return0;}
22.Secitescdouanumerecarecontincatetreicifrefiecare.Saseafisezenumarulformatdinprima
cifradelaprimulnumar,cifraadouaceamaimaredelaambelenumeresicifraatreiadelaultimul
numar.
Algoritm:
Start
Citestea,b
Dacaa>=100sia<=1000sib>=100sib<=1000atunci
Dacarest(cat(a,10),10)>rest(cat(b,10),10)atunci
Tiparestenumaruleste,cat(a,10)*10+rest(b,10)
Altfel
Tiparestenumaruleste,cat(a,100)*100+rest(b,100)
Sfarsitdaca
Altfel
Tiparestenumerelenusuntformatedintreicifre
Sfarsitdaca
Stop
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
intC1,C2,a;
intmain(){
cout<<"a=";cin>>a;
C1=a/100;
C2=a%100;
cout<<"catuleste"<<C1/C2;
cout<<"restuleste"<<C1%C2;
getch();
return0;}
23.Secitesteunnumarcarecontineexacttreicifre.Sasedeterminecelmaimarenumarcarese
poateformadincifrelesale.

Algoritm:
Start
Citestea
C1=cat(a,100)
C2=rest(cat(a,10),10)
C3=rest(a,10)
DacaC1>C2siC2>C3atunci
TiparesteC1*100+C2*10+C3
Altfel
DacaC1>C3siC3>C2atunci
TiparesteC1*100+C3*10+C2
Altfel
DacaC2>C1siC1>C3atunci
TiparesteC2*100+C1*10+C3
Altfel
DacaC2>C3siC3>C1atunci
TiparesteC2*100+C3*10+C1
Altfel
DacaC3>C1siC1>C2atunci
TiparesteC3*100+C1*10+C2
Altfel
TiparesteC3*100+C2*10+C1
Sfarsitdaca
Sfarsitdaca
Sfarsitdaca
Sfarsitdaca
Sfarsitdaca
Stop
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
inta,C1,C2,C3;
intmain(){
cout<<"a=";cin>>a;
C1=a/100;
C2=(a/10)%10;
C3=a%10;
if(C1>C2&&C2>C3)
cout<<C1*100+C2*10+C3;
else
if(C1>C3&&C3>C2)
cout<<C1*100+C3*10+C2;
else
if(C2>C1&&C1>C3)
cout<<C2*100+C3*10+C1;
else
if(C2>C3&&C3>C1)
cout<<C2*100+C3*10+C1;
else
cout<<C3*100+C2*10+C1;

getch();
return0;}
24.Secitesteunnumar.Sasedeterminesumacifrelorsale.
Algoritm:
Start
Citesten
S=0
Cattimpn#0executa
S=S+rest(n,10)
n=cat(n,10)
Sfarsitcattimp
TiparestesumaesteS
Stop
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
intn,S;
intmain(){
cout<<"n=";cin>>n;
S=0;
while(n)
{S=S+n%10;
n=n/10;}
cout<<"Sumaeste"<<S;
getch();
return0;}
25.Sasescrieunalgoritmcarecitestesumacifrelorparesisumacifrelorimparealeunuinumar.
Algoritm:
Start
Citesten
P=0
Cattimpn!=0executa
Dacarest(n,2)=0atunci
P=P+rest(n,10)
Altfel
I=I+rest(n,10)
Sfarsitdaca
n=cat(n,10)
Sfarsitcattimp
TiparesteSumacifrelorpareeste,P,iarsumacifrelorimpareeste,I;
Stop
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
intP,I,n;
intmain(){
cout<<n=;cin>>n;
P=0;I=0;
While(n!=0)

If(n%2==0)
P+=n%10;
Else
I+=n%10;
cout<<Sumacifrelorpareeste<<P<<,<<iarsumacifrelorimpareeste<<I;
getch();
return0;}
26.Sasescrieunalgoritmcarecitesteunnumarsinumaracatecifreparesicateimpareare
numarul.
Algoritm:
Start
Citesten
P=0
I=0
Cattimpn!=0executa
Dacarest(n,2)=0atunci
P=P+1
Altfel
I=I+1
Sfarsitdaca
n=cat(n,10)
Sfarsitcattimp
TiparesteNumarulare,P,cifreparesi,I,cifreimpare;
Stop
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
intn,P,I;
intmain(){
cout<<n=;cin>>n;
P=0;I=0;
While(n!=0)
If(n%2==0)
P+=1;
else
I+=1;
cout<<Numarulare<<P<<cifreparesi<<I<<cifreimpare;
getch();
return0;}
27.Secitesteunnumar.Sasedetermineoglindanumarului.
Algoritm:
Start
Citesten
P=0
Cattimpn!=0executa
P+=rest(n,10)
n=cat(n,10)
Sfarsitcattimp
TiparesteOglindanumaruluicititeste,P;
Stop

Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
intn,P;
intmain(){
cout<<n=;cin>>n;
P=0;
While(n!=0)
P=P*10+(n%10);
n=n/10;
cout<<Oglindanumaruluicititeste<<P;
getch();
return0;

28.Secitesteunnumar.Sasedeterminedacanumarulestepalindrom.
Algoritm:
Start
Citesten
A=n
P=0
Cattimpn!=0executa
P=P*10+rest(n10)
n=cat(n,10)
Sfarsitcattimp
DacaA=Patunci
TiparesteNumarulestepalindrom
Altfel
TiparesteNumarulnuestepalindrom
Sfarsitdaca
Stop
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
intn,A,P;
intmain(){
cout<<n=;cin>>n;
A=n;P=0;
while(n!=0)
P=P*10+(n%10);
n=n/10;
If(A=P)
Cout<<Numarulestepalindrom;
Else
Cout<<Numarulnuestepalindrom;
Getch();
Return0;}
29.Secitescdouanumeresasedeterminecelmaimaredivizorcomunalcelordouanumere.
Algoritm:

Start
citestea,b
x=a
y=b
Cattimpa=!bexecuta
Dacaa>batunci
a=ab
altfel
b=ba
Sfarsitdaca
Sfarsitcattimp
Tipareste"celmaimicdivizorcomun(",x,",",y,")=",b
Stop
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
intn,p,a,b,x,y,i;
intmain(){
cout<<"a=";cin>>a;
cout<<"b=";cin>>b;
x=a;
y=b;
while(a=!b)
{if(a>b)
a=ab;
else
b=ba;}
cout<<"celmaimaredivizorcomunesteanr"<<x<<","<<y<<"este"<<a;
getch();
return0;}
30.Unbancherareunseifcucifru,pentruanuluitacifruvreasascriepeofoaiecodificat.
Fiecarecifrasafieinlocuitacudiferentadintrecifranouasicifrarespectiva.
Siaalesuncifruajutatilsalcodifice.Cifraestediferitadenoua.
Algoritm:
START
citesten

P=0
Cattimpn=!0executa
P=p*10+9rest(n,10)
n=cat(n,10)
Sfarsitcattimp
A=0
CattimpP=!0executa
A=A*10+rest(P,10)
P=cat(P,10)
Sfarsitcattimp
Tipareste"cifrulcodificateste"A
STOP
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
intn,maxd,a,p,x,i;
intmain(){
cout<<"n=";cin>>n;
p=0;
while(n)
{p=p*10+9n%10;
n=n/10;}
a=0;
while(p)
{a=a*10+p%10;
p=p/10;}
cout<<"cifrulcodificateste"<<a;
getch();
return0;}
31.Secitesteunnumarsaseafisezedivizoriilui.
Algoritm:
Start
Citesten
Pentrui=1lan
Dacarest(n,i)=0atunci
Tiparestei,","

Sfarsitdaca
Sfarsitpentru
STOP
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
intn,i;
intmain(){
cout<<"n=";cin>>n;
for(i=1;1<n;i++)
if(n%i==0)
cout<<i<<"";
getch();
return0;}

32.Secitesteunnumarsasenumerecatidivizoripozitiviarenumarul.
Algoritm:
START
Citesten
d=0
Pentrui=1lan
Dacarest(n,i)=0atunci
d=d+1
Sfarsitdaca
Sfarsitpentru
Tiparesten"are",d"divizori"
STOP
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
longn,I,d;
intmain(){
cout<<n=;cin>>n;
d=0;
for(i=1;i<=n;i++)
if(n%i==0)
d++;
cout<<numarul<<n<<are<<d<<divizori;

getch();
return0;}
33.Secitesteunnumarnsasedeterminedacaelesteprimsaunu.
Algoritm:
Start
Citesten
Prim=1
Pentrui=2lan1
Dacarest(n,i)=oatunci
Prim=0
Sfarsitdaca
Sfarsitpentru
Dacaprim=1
Tipareste,,numarulesteprim
Altfel
Tipareste,,numarulnuesteprim
Sfarsitdaca
Stop
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
intprim,n,d;
intmain(){
cout<<"n=";cin>>n;
prim=1;
for(d=2;d<n;d++)
{if(n%d==0)
prim=0;}
if(prim==1)
cout<<"numarulesteprim";
else
cout<<"numarulnuesteprim";
getch();
return0;}
34.Saseafisezetoatenrprimede4cifrecareauultimele2cifreleinordinecrescatoare.
Algoritm:
START
Pentrui=1000la9999
Prim=1
PentruD=2lai1
Dacarest(i,D)=0atunci
Prim=0
Sfarsitdaca
Gasitcresc=1
Cattimp(D=!0)executa
Dacarest(D,10)>rest(cat(D,10),10)
gasitcresc=0
D=cat(D,10)
sfarsitdaca
Sfarsitcattimp

Dacaprim*gasitcresc!=0
TiparesteD
sfarsitdaca
Sfarsitpentru
STOP
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
intn;
intmain(){
cout<<"n=";cin>>n;
if(n%10>(n/10)%10)
cout<<"numarulrespectaconditia";
else
cout<<"numarulnurespectaconditia";
getch();
return0;}
35.Sasenumerecatenumerede5cifrecontin3cifreparesiultimele3cifreinordine
descrescatoare.
Algoritm:
START
S=0
Pentrui=10000la99999
P=0
X=i
Cattimpx!=0executa
Dacarest(x,2)=0atunci
P=P+1
Sfarsitdaca
X=cat(x,10)
Sfarsitcattimp
DacaP=3SIrest(i,10)<rest(cat(i,10)10)sirest(cat(i,10),10)<rest(cat(I,100),10)atunci
S=S+1
Sfarsitdaca
Sfarsitpentru
TiparesteS
STOP
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
intn,i,j,par,g,d,s;
intmain()
{s=0;
for(i=10000;i<100000;i++)
{par=0;
d=i;
while(d)
{if(d%2==0)
par++;}

if((par==3)&&(i%10)<(i/10)%10&&(i/10)%10<(i/100)%10)
s++;
cout<<s;}
getch();
return0;}
36.Secitesteunnumarnaturalnde4cifre.afisatidacaaresaunuultimele2cifreleinordine
crescatoare.
Algoritm:
start
citesten
dacarest(n,10)>rest(cat((n,10))atunci
tipareste"numarulrespectaonditia
altfel
tiparestenumarulnurespectaconditia
sfarsitdaca
stop
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
intn;
intmain(){
cout<<"n=";cin>>n;
if(n%10>(n/10)%10)
cout<<"numarulrespectaconditia";
else
cout<<"numarulnurespectaconditia";
getch();
return0;}
37.EcuatiadegradulII
Algoritm:
Start
Citestea,b,c
Dacaa=0,atunci
Dacab=0,atunci
Dacac=0,atunci
Tiparestex1,x2oricenumarreal
Altfel
Tiparesteecuatiaimposibila
Sfarsitdaca
Altfel
Tiparestex=,
Sfarsitdaca
Altfel
=b24ac
Daca0atunci
x1=

x2=

Tiparestex1=,x1
Tiparestex2=,x2

Altfel
Tiparestenuavemsolutiireale
Sfarsitdaca
Sfarsitdaca
Stop
Program:
#include<iostream>
#include<conio.h>
#include<math.h>
usingnamespacestd;
inta,b,c,d;
floatx1,x2;
intmain(){
cout<<"a=";cin>>a;
cout<<"b=";cin>>b;
cout<<"c=";cin>>c;
if(a==0)
if(b==0)
if(c==0)
cout<<"x1,x2oricenumarreal";
else
cout<<"x="<<c/b;
else
{d=b*b4*a*c;
if(d>=0)
{x1=(b+sqrt(d))/(2*a);
x2=(bsqrt(d))/(2*a);
cout<<"x1="<<x1;
cout<<"x2="<<x2;}
else
cout<<"nuavemsolutiireale";}
getch();
return0;}
38.Secitesteunnumardemaxim5cifre,intreg,pozitiv,saseafisezenumarul.
Algortim:
Start
Citesten
Dacan<10,atunci
Tiparesteareocifra
Altfel
Dacan<100,atunci
Tiparestearedouacifre
Altfel
Dacan<1000,atunci
Tiparestearetreicifre
Altfel
Dacan<10000,atunci
Tiparestearepatrucifre
Altfel
Dacan<100000,atunci
Tiparestearecincicifre

Stop
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
inta;
intmain(){
cout<<"a=";cin>>a;
if(a<10)
cout<<"areocifra";
else
if(a<100)
cout<<"aredouacifre";
else
if(a<1000)
cout<<"aretreicifre";
else
if(a<10000)
cout<<"arepatrucifre";
else
if(a<100000)
cout<<"arecincicifre";
getch();
return0;}
39.Secitescdouanumeresaseafisezecaredintreeleestemaimare.
Algoritm:
Start
Citestea,b
Dacaa>b,atunci
Tiparestea
Altfel
Dacab>a,atunci
Tiparesteb
Sfarsitdaca
Sfarsitdaca
Stop
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
inta,b;
intmain(){
cout<<"a=";cin>>a;
cout<<"b=";cin>>b;
if(a>b)
cout<<"numarulmaimareeste"<<a;
else
if(b>a)
cout<<"numarulmaimareeste"<<b;
else
cout<<"numerelesuntegale";

getch();
return0;}
40.Secitesctreinumeresaseafisezecaredintreeleestemaimare.
Algoritm:
Start
Citestea,b,c
Dacaa>bsia>c,atunci
Tiparestea
Altfel
Dacab>csib>a,atunci
Tiparesteb
Altfel
Tiparestec
Sfarsitdaca
Sfarsitdaca
Stop
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
inta,b,c;
intmain(){
cout<<"a=";cin>>a;
cout<<"b=";cin>>b;
cout<<"c=";cin>>c;
if(a>b)
if(a>c)
cout<<"numarulmaimareeste"<<a;
else
cout<<"numarulmaimareeste"<<c;
else
if(b>c)
cout<<"numarulmaimareeste"<<b;
else
cout<<"numarulmaimareeste"<<c;
getch();
return0;}
41.Secitesc4nrintregi.Sasedeterminedacacelputin2nrsuntpozitive.
Algortim:
Start
Citestea,b,c,d
Daca(a>0sib>0)sau(a>0sic>0)sau(a>0sid>0)sau(b>0sic>0)sau(b>0sid>0)sau(c>0sid>0)
Tiparesteavemcelputin2nrpozitive
Altfel
Tiparestenuavemcelputin2nrpozitive
Sfarsitdaca
Stop
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;

inta,b,c,d;
intmain()
{cout<<"a=";cin>>a;
cout<<"b=";cin>>b;
cout<<"c=";cin>>c;
cout<<"d=";cin>>d;
if((a>0&&b>0)||(a>0&&c>0)||(a>0&&d>0)||(b>0&&c>0)||(b>0&&d>0)||(c>0&&d>0))
cout<<"avemcelputin2nrpozitive";
else
cout<<"nuavem2nrpozitive";
getch();
return0;}

42.Secitesc2nr.Saseafisezecarenresteparsicareesteimpar.
Algoritm:
Start
Citestea,b
Dacarest(a,2)=0atunci
Tiparestea,estepar
Altfel
Tiparestea,esteimpar
Sfarsitdaca
Dacarest(b,2)0atunci
Tiparesteb,esteimpar
Altfel
Tiparesteb,estepar
Sfarsitdaca
Stop
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
inta,b;
intmain()
{cout<<"a=";cin>>a;
cout<<"b=";cin>>b;
if(a%2==0)
cout<<a<<"estepar";
else
cout<<a<<"esteimpar";
if(b%2!=0)
cout<<b<<"esteimpar";
else
cout<<b<<"estepar";
getch();
return0;}
43.Secitesc3nr.Sasedeterminedacapotfilaturileunuitriunghisisasedeterminetipul
triunghiului,perimetrulsiariaacestuia.
Algoritm:
Start
Citestea,b,c

Dacaa>0sib>0sic>0sia+b>csia+c>bsib+c>aatunci
Tiparestepotreprezentalaturileunuitriunghi
Dacaa=bsia=catunci
Tiparestetriunghiulesteechilateral
Altfel
Dacaa=bsaua=csaub=catunci
Tiparestetriunghiulesteisoscel
Sfarsitdaca
Dacaa+b=csaua+c=bsauc+b=aatunci
Tiaprestetriunghiulestedreptunghic
Sfarsitdaca
Dacaabsiacsibcsia+bcsib+casia+c=batunci
Tiparestetriunghiulesteoarecare
Sfarsitdaca
Sfarsitdaca
P=a+b+c
Tiparesteperimetruleste,P
p=P/2
A=p(pa)(pb)(pc)
Tiparesteariaeste,A
Altfel
Tiparestenupotreprezentalaturileunuitriunghi
Sfarsitdaca
Stop
Program:
#include<iostream>
#include<conio.h>
#include<math.h>
usingnamespacestd;
inta,b,c;
floatA,P;
intmain()
{cout<<"a=";cin>>a;
cout<<"b=";cin>>b;
cout<<"c=";cin>>c;
if(a>0&&b>0&&c>0&&a+b>c&&b+c>a&&a+c>b)
cout<<"potreprezentalaturileunuitriunghi";
if(a==b&&a==c)
cout<<"triunghiulesteechilateral";
else
if(a==b||a==c||b==c)
cout<<"triunghiulesteisoscel";
else
if(a*a+b*b==c*c||a*a+c*c==b*b||b*b+c*c==a*a)
cout<<"triunghiulestedreptunghic";
else
cout<<"triunghiulesteoarecare";
P=a+b+c;
cout<<"perimetruleste"<<P<<endl;
P=P/2;
A=sqrt(P*(Pa)*(Pb)*(Pc));

cout<<"ariaeste"<<A;
getch();
return0;}
44.Secitesc3nr.Sasedeterminedacapotfiunghiurileunuitriunghisisasedeterminetipul
triunghiului.
Algoritm:
Start
Citestea,b,c
Dacaa>0sib>0sic>0sia+b+c=180atunci
Tiparestepotreprezentaunghiurileunuitriunghi
Dacaa=bsia=catunci
Tiparestetriunghiulesteechilateral
Altfel
Dacaa=90saub=90sauc=90atunci
Tiparestetriunghiulestedreptunghic
Altfel
Dacaa=bsaua=csaub=catunci
Tiparestetriunghiulesteisoscel
Altfel
Tiparestetriunghiulesteoarecare
Sfarsitdaca
Sfarsitdaca
Sfarsitdaca
Altfel
Tiaprestenupotreprezentaunghiurileunuitriunghi
Sfarsitdaca
Stop
Program:
#include<iostream>
#include<conio.h>
#include<math.h>
usingnamespacestd;
inta,b,c;
intmain()
{cout<<"a=";cin>>a;
cout<<"b=";cin>>b;
cout<<"c=";cin>>c;
if(a>0&&b>0&&c>0&&a+b+c=180)
cout<<"potreprezentaunghiurileunuitriunghi";
if(a==b&&a==c)
cout<<"triunghiulesteechilateral";
else
if(a==b||a==c||b==c)
cout<<"triunghiulesteisoscel";
else
if(a==90||b==90||c==90)
cout<<"triunghiulestedreptunghic";
else
cout<<"triunghiulesteoarecare";
else
cout<<"nupotreprezentaunghiurileunuitriunghi";

getch();
return0;}
45.Secitescnnumerecarecontinexact5cifre.Sasedeterminenumerele.
Algoritm:
Start
Citestea
S=0
C5=rest(a,10)
C4=rest(cat(a,10),10)
C3=rest(cat(a,100),10)
C2=rest(cat(a,1000),10)
C1=cat(a,10000)
S=C1+C2+C3+C4+C5
TiparesteSumaeste,S
Stop
Program:
#include<iostream>
#include<conio.h>
Usingnamespacestd;
Inta,S;
Intmain(){
Cout<<a=;cin>>a;
C5=a%10;
C4=(a/10)%10;
C3=(a/100)%10;
C2=(a/1000)%10;
C1=a/10000;
S=C1+C2+C3+C4+C5;
Cout<<Sumaeste<<S;
Getch();
Return0;}
46.Secitesc3numere.Sasedeterminedacacele3numerepotficonsecutive.
Algoritm:
Start
Citestea,b,c
Daca(b=a+1sic=a+2)
Tiparestea,b,c
Altfel
Daca(c=a+1sib=a+2)
Tiparestea,c,b
Altfel
Daca(a=b+1sic=b+2)
Tiparesteb,a,c
Altfel
Daca(c=b+1sia=b+2)
Tiparesteb,c,a
Altfel
Daca(a=c+1sib=c+2)
Tiparestec,a,b
Altfel
Daca(b=c+1sia=c+2)

Tiparestec,b,a
Altfel
TiparesteNupotfiasezateconsecutive
Sfarsitdaca
Sfarsitdaca
Sfarsitdaca
Sfarsitdaca
Sfarsitdaca
Sfarsitdaca
Stop
Program:
#include<iostream>
#include<conio.h>
Usingnamespacestd;
Inta,b,c;
Intmain(){
Cout<<a=;cin>>a;
Cout<<b=;cin>>b;
Cout<<c=;cin>>c;
If(b==a+1&&c==a+2)
Cout<<a<<,<<b<<,<<c<<endl;
Else
If(c==a+1&&b==a+2)
Cout<<a<<,<<c<<,<<b<<endl;
Else
If(a==b+1&&c==b+2)
Cout<<b<<,<<a<<,<<c<<endl;
Else
If(c==b+1&&a==b+2)
Cout<<b<<,<<c<<,<<a<<endl;
Else
If(a==c+1&&b==c+2)
Cout<<c<<,<<a<<,<<b<<endl;
Else
If(b==c+1&&a==c+2)
Cout<<c<<,<<b<<,<<a<<endl;
Else
Cout<<Nupotfiasezateconsecutive
Getch();
Return0;}
47.Secitescnnumerecareauexact3cifre.Sasedeterminecelmaimarenumarcarepoatefiformat
dincifrelesale.
Algoritm:
Start
Citestea,c1,c2,c3
C1=cat(a,100)
C2=rest(cat(a,10),10)
C3=rest(a,10)
Daca(c1>c2sic2>c3)
Tiparestec1*100+c2*10+c3;
Altfel

Daca(c1>c3sic3>c2)
Tiparestec1*100+c3*10+c2;
Altfel
Daca(c2>c1sic1>c3)
Tiparestec2*100+c1*10+c3;
Altfel
Daca(c2>c3sic3>c1)
Tiparestec2*100+c3*10+c1;
Altfel
Daca(c3>c1sic1>c2)
Tiparestec3*100+c1*10+c2;
Altfel
Daca(c3>c2sic2>c1)
Tiparestec3*100+c2*10+c1;
Altfel
TiparesteSuntcelputin3cifreegale;
Sfarsitdaca
Sfarsitdaca
Sfarsitdaca
Sfarsitdaca
Sfarsitdaca
Stop
Program:
#include<iostream>
#include<conio.h>
Usingnamespacestd;
Intc1,c2,c3,a
Intmain(){
Cout<<n=;cin>>n;
Cout<<a=;cin>>a;
C1=a/100;
C2=(a/10)%10;
C3=a%10;
If(c1>c2&&c2>c3)
Cout<<c1*100+c2*10+c3;
Else
If(c1>c3&&c3>c2)
Cout<<c1*100+c3*10+c2;
Else
If(c2>c1&&c1>c3)
Cout<<c2*100+c1*10+c3;
Else
If(c2>c3&&c3>c1)
Cout<<c2*100+c3*10+c1;
Else
If(c3>c1&&c1>c2)
Cout<<c3*100+c1*10+c2;
Else
If(c3>c2&&c2>c1)
Cout<<c3*100+c2*10+c1;
Else

Cout<<Suntcelputin3cifreegale;
Getch();
Return0;}
48.Secitesc3numere.Saseafisezeinordinecrescatoare
Algoritm:
Start
Citestea,b,c
Daca(a>bsib>c)
Tiparestec<b<a;
Altfel
Daca(a>csic>b)
Tiaresteb<c<a;
Daca(b>asia>c)
Tiparestec<a<b;
Altfel
Daca(b>csic>a)
Tiparestea<c<b;
Altfel
Daca(c>asia>b)
Tiparesteb<a<c;
Altfel
Daca(c>bsib>a)
Tiparestea<b<c;
Altfel
TiparesteCele3numeresuntegale
Stop
Program:
#include<iostream>
#include<conio.h>
Usingnamespacestd;
Inta,b,c;
Intmain(){
Cout<<a=;cin>>a;
Cout<<b=;cin>>b;
Cout<<c=;cin>>c;
If(a>b&&b>c)
Cout<<c<<<<<b<<<<<a;
Else
If(a>c&&c>b)
Cout<<b<<<<<c<<<<<a;
If(b>a&&a>c)
Cout<<c<<<<<a<<<<<b;
Else
If(b>c&&c>a)
Cout<<a<<<<<c<<<<<b;
Else
If(c>a&&a>b)
Cout<<b<<<<<a<<<<<c;
Else
If(c>b&&b>a)
Cout<<a<<<<<b<<<<<c;

Else
Cout<<Cele3numeresuntegale
Getch();
Return0;}
49.Secitesc4numere,sasedeterminedaprintrecele4sunt3pozitive.
Algoritm:
Start
Citestea,b,c,d;
Daca(a>0sib>0sic>0)sau(a>0sib>0sid>0)sau(a>0sic>0sid>0)sau(b>0sic>osid>o)atunci
Tipareste"exista3numerepozitive"
Altfel
Tipareste"nuexista3numerepozitive"
Sfarsitdaca
Stop
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
inta,b,c,d;
intmain(){
cout<<"a=";cin>>a;
cout<<"b=";cin>>b;
cout<<"c=";cin>>c;
cout<<"d=";cin>>d;
if(a>0&&b>0&&c>0)||(a>0&&b>0&&d>0)||(a>0&&c>0&&d>0)||(b>0&&c>0&&d>0)
cout<<"exista3numerepozitive";
else
cout<<"nuexista3numerepozitive";
getch();
return0;}
50.Cunoscanddatadenastereauneipersoaneexprimatainani,lunasiziuasidatacurenta
exprimatalafel,sasearatevarstauneipersoaneinaniimpliniti.
Algoritm:
Start
CitesteZn,Ln,An,Zc,Lc,Ac
DacaLc>=Lnatunci
Tipareste"varstaeste",AcAn
Altfel
DacaZc>=Znatunci
Tipareste"carstaeste",AcAn
Altfel
Tipareste"varstaeste",AcAn1
Sfarsitdaca
Sfarsitdaca
Stop
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
intZn,Ln,An,Zc,Lc,Ac;
intmain(){

cout<<"Zn=";cin>>Zn;
cout<<"Ln=";cin>>Ln;
cout<<"An=";cin>>An;
cout<<"Zc=";cin>>Zc;
cout<<"Lc=";cin>>Lc;
cout<<"Ac=";cin>>Ac;
{if(Lc>=Ln)
cout<<"Varstaeste"<<AcAn;
else
if(Zc>=Zn)
cout<<"Varstaeste"<<AcAn;
else
cout<<"Varstaeste"<<AcAn1;
getch();
return0;}
51.Sasedeterminedacaunnumar"n"esteperfect,dacaesteegalcusumadivizorilorlui.
Algoritm:
Start
Citesten,S,i
S=o
Pentrui=1lan
Dacarest(n,i)=0atunci
S=S=i
DacaS=natunci
Tipareste"esteperfect"
Altfel
Tipareste"nuesteperfect"
Sfarsitdaca
Sfarsitdaca
Sfarsitpentru
Stop
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
intn,S,i;
intmain(){
cout<<"n=";cin>>n;
S=0;
for(i=1;i<n;i++)
if(n%i==0)
S=S+i;
if(S==n)
cout<<n<<"esteperfect";
else
cout<<n<<"nuesteperfect";
getch();
reutrn0;}
52.Secitesteunnumar"x"saseafisezetoatenumereleperfectdintre1six.
Algoritm:
Start

citestex,n,i,S
Pentrun=6lax
S=o
Pentrui=1lan
Dacarest(n,i)=0atunci
S=S+i
Sfarsitdaca
Sfarsitpentru
DacaS=natunci
Tiparesten
Sfarsitdaca
Sfarsitpentru
Stop
Program:
#incude<iostream>
#include<conio.h>
usingnamespacestd;
intx,n,i,S;
intmain(){
cout<<"x=";cin>>x;
for(n=6;n<x;n++)
{S=0;
for(i=1;i<n;i++)
if(n%i==0)
S=S=i;
if(S==n)
cout<<n;}
getch();
return0;}
53.Aflatisumanumerelorparedela1la105.
Algoritm:
START
Citestei
s=0
Pentrui=2la104pas2
s=s+i
Tipareste"Sumaeste",s,"."
Sfarsitpentru
STOP
Program:
#include<iostream>
#include<conio.h>

#include<math>
usingnamespacestd;
ints,i;
intmain(){
s=0;
for(i=2;i<=104;i=i+2)
s=s+i;
cout<<"Sumaeste"<<s<<".";
getch();
return);}
54.Secitesteunnumar.Sasedeterminedacaesteprim.
Algoritm:
START
Citesten
prim=1
Pentrui=2lan1
Dacarest(n,i)=0atunci
prim=0
Sfarsitdaca
Sfarsitpentru
Dacaprim=1atunci
Tiparesten,"esteprim."
Altfel
Tiparesten,"nuesteprim."
Sfarsitdaca
STOP
Program:
#include<iostream>
#include<conio.h>
#include<math.h>

usingnamespacestd;
intn,prim,i;
intmain(){
cout<<"n=";cin>>n;
prim=1;
for(i=2;i<n;i=i+1)
if(n%i==0)
prim=0;
if(prim!=0)
cout<<n<<"esteprim.";
else
cout<<n<<"nuesteprim.>>
getch();
return0;}
55.Secitesteunnumark.Afisatitoatenumereleprimemaimicidecatksimaimaridecat1.
Algoritm:
START
Citestek
Pentrun=2lak1
Dacarest(n,i)=0atunci
prim=0
Sfarsitdaca
Dacaprim=1atunci
Tiparesten,""
Sfarsitdaca
Sfarsitpentru
STOP
Program:
#include<iostream>
#include<conio.h>

#include<math.h>
usingnamespacestd;
intk,prim,n,i;
intmain(){
cout<<"k=";cin>>k;
{for(n=1;n<=k;n=n+1)
if(n%i==0)
prim=0;
if(prim==1)
cout<<n<<"";}
getch();
return0;}
56.Saseafisezetoatenumerelede4cifrecareauultimele3cifreinorinecrescatoare.
Algoritm:
START
Pentrun=1000la10000
c=rest(cat(i,100),10)
c=rest(cat(i,10),10)
c=rest(i,10)
Dacac<csic<catunci
Tiparestei,""
Sfarsitdaca
Sfarsitpentru
STOP
Program:
#include<iostream>
#include<conio.h>
#include<math.h>
usingnamespacestd;
inti,c,c,c;p

intmain(){
for(i=1000;i<10000;i+1)
{c=(i/100)%10;
c=(i/10)%10;
c=i%10;
if(c<c&&c<c)
cout<<i<<"";}
getch();
return0;}
57.Saseafisezenumerelede5cifrecarerespectaurmatoareleconditii:primacifraplusultimasafie
egalacusumadintrecifraa2sicifraa4aiarcifraa3esteparaiarsumatuturorcifreloresteimpara.
Algoritm:
Start
Citesten
Pentrun=10000la100000pas1
c1=(cat(n,10000)
c2=rest(cat(n,1000),10)
c3=rest(cat(n,100),10)
c4=rest(cat(n,10),10)
c5=rest(a,10)
dacac1+c5=c2+c4sirest(c,2)=0sirest((c1+c2+c3+c4+c5),2)diferitde0atunci
Tiparesten
Sfarsitpentru
Sfarsitdaca
Stop
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
longn,c1,c2,c3,c4,c5;
intmain(){
for(n=10000;n<100000;n=n+1)
c1=(n/10000)%10;
c2=(n/1000)%10;
c3=(n/100)%10;
c4=(n/10)%10;
c5=n%10;
if((c1+c5==c2+c4)&&(c3%2==0)&&(c1+c2+c3+c4+c5)%2!=0)
cout<<n<<"";
getch();
return0;}
58.Secitesteunnumar.Sasedeterminedacanresteegalcusumadivizorilorsaimaiputinelinsusi.
Algoritm
Start
Citesten

Pentrud=1lanpas1
Dacarest(n,d)=0atunci
S=S+d
Dacan=Satunci
Tipareste"nestenumarperfect"
Altfel
Tipareste"nnuestenumarperfect"
Sfarsitpentru
Sfarsitdaca
Sfarsitdaca
Stop
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
intn,d,S;
intmain(){
cout<<"n=";cin>>n;
S=0;
for(d=1;d<n;d++)
if(n%d==0)
S=S+d;
if(n==S)
cout<<n<<"esteperfect";
else
cout<<n<<"nuesteperfect";
getch();
return0;}
59.Saseciteascaunnumark,saseafisezetoatenumereleperfectecuprinseintre1sik.
Algoritm:
Start
Citesten
Pentrun=2lakpas1
S=0
Pentrui=1lanpas1
Dacarest(n,i)=0atunci
S=S+i
Dacan=Satunci
Tiparesten
Sfarsitpentru
Sfarsitpentru
Sfarsitdaca
Sfarsitdaca
Stop
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
intk,n,i,S;

intmain(){
cout<<"k=";cin>>k;
for(n=2;n<k;n++)
S=0;
for(i=1;i<n;i++)
if(n%i==0)
S=S+i;
if(n==S)
cout<<n<<"";
getch();
return0;}
60.Secitesteunnumarsasedeterminetoatenumerelede4cifrecareauexactkdivizorisi2cifre
egale.
Algoritm:
Start
Citesten
Pentrun=1000la10000pas1
D=0
Pentrui=1lanpas1
Dacarest(n,i)=oatunci
D=D+1
DacaD=nsicat(n,1000)=rest(cat(n,100),10)saucat(n,1000)=rest(cat(n,10),10)sau
cat(n,1000)=rest(n,10)saurest(cat(n/100),10)=rest(cat(n,10),10)saurest(cat(n,100),10)=rest(n,10)
saurest(cat(n,10),10)=rest(n,10)atunci
Tiparesten
Sfarsitpentru
Sfarsitpentru
Sfarsitdaca
Sfarsitdaca
Stop
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
intk,n,D,i;
intmain(){
cout<<"n=";cin>>n;
cout<<"k=";cin>>k;

for(n=1000;n<10000;n=n+1)
D=0;
for(i=1;i<n;i++)
if(n%i==0)
D=D+1;
if(D==k&&
((n/1000==(n/100)%10)||(n/1000==(n/10)%10)||(n/1000==n%10)||(n/100)%10==(n/10)%10||(n/1
00)%10==n%10||(n/10)%10==n%10))
cout<<n<<"";
getch();
return0;}
61.Secitesteunnumar.Sasedeterminesumacifrelor.
Algoritm:
Start
Citesten,S,i
S=0
i=n
Cattimpn!=0executa
S=S+rest(n,10)
n=cat(n,10)
Sfarsitcattimp
TiparesteSumacifrelorlui,i,este,S.
Stop
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
intn,S,i;
intmain(){cout<<"n=";cin>>n;
S=0;
i=n;
while(n!=0)
{S=S+n%10;
n=n/10;}
cout<<"sumacifrelorlui"<<i<<"este"<<S;
getch();
return0;}
62.Sasedeterminesumacifrelorparesisumacifrelorimpareanumaruluin.
Algoritm:
Start
Citesten,P,i
P=i=0
Cattimpn=0executa
Dacarest(n,2)=0atunci
P=P+rest(n,10)

Altfel
i=i+rest(n,10)
n=cat(n,10)
Sfarsitdaca
Sfarsitcattimp
TiparesteSumacifrelorimpareeste,i.
TiparesteSumacifrelorpareeste,P.
Stop
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
intn,P,i;
intmain(){cout<<"n=";cin>>n;
P=i=0;
while(n!=0)
{if(n%2==0)
P=P+n%10;
i=i+n%10;
n=n/10;}
cout<<"sumacifrelorimpareeste"<<i;
cout<<"sumacifrelorpareeste"<<P;
getch();
return0;}
63.Secitesteunnumar.Sasenumeredecareoriintraunfactorpindescompunereasa.
Algoritm:
Start
Citesten,p,A,x,i
A=0
x=n
Cattimprest(n,p)=0executa
A=A+1
n=cat(n,p)
Sfarsitcattimp
Tiparestep,intraindescompunerealui,x,de,A,ori
Stop
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
intn,p,A,x,i;
intmain(){cout<<"n=";cin>>n;
cout<<"p=";cin>>p;
A=0;
xn;
while(n%i==0)
{A++;
n=n/p;}
cout<<p<<"intraindescompunerealui"<<x<<"de"<<A<<"ori";
getch();
return0;}

64.Secitesteunnumar.Saseafisezedescompunereainfactoriprimi.
Algoritm:
Start
Citesten,p,A,i
Pentrui=2lanpas1
A=0
Cattimprest(n,i)=0executa
A=A+1
n=cat(n,i)
Sfarsitcattimp
DacaA!=0atunci
Tiparestei,^,A,*
Sfarsitdaca
Sfarsitpentru
Stop
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
intn,P,A,i;
intmain(){cout<<"n=";cin>>n;
cout<<n<<"=";
{A=0;
while(n%i==0)
{A++;
n=n/i;}
if(A!=0)
cout<<i<<"^"<<A<<"*";}
getch();
return0;}
65.secitescnnumere.Sasedeterminecatedintreelenuapartinintervalului(a,b)undeasibsuntnr
intrgi.
Algoritm:
Start
Citesten
P=0
Pentrui=1lan
Dacai<asaui>batunci
P++
Sfarsitdaca
Sfarsitpentru
TiparesteP
Stop

Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
intn,a,b,p,x,i;
intmain(){
cout<<"a=";cin>>a;
cout<<"b=";cin>>b;
cout<<"n=";cin>>n;
p=0;
for(i=1;i<=n;i++)
{cout<<"x=";cin>>x;
if(x<a||x>b)
p++;}
cout<<"saugasit"<<p<<"numereinafaraintervalul("<<a<<","<<b<<")";
getch();
return0;}
66.secitescnnumere.Sasedeterminecareestecifraceamaimaredintretoate.
Algoritm:
Start
Citesten,
Max=0
Pentrui=1lan
Citestex
Cattimpx=!0executa
Dacamax<rest(x,10)
Max=rest(x,10)
Sfarsitdaca
x=cat(x,10)
sfarsitcattimp

tiparestemax
stop
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
intn,maxd,x,i;
intmain(){
cout<<"n=";cin>>n;
maxd=0;
for(i=1;i<=n;i++)
{cout<<"x=";cin>>x;
while(x)
{if(x%10>maxd)
maxd=x%10;
x=x/10;}}
cout<<maxd;
getch();
return0;}
67.Secitesteunnrnsasescrieunprogramcareafiseazatotidivizoriisai.
Algoritm:
Start
Citesten
Pentrud=1lan
Dacarest(n,d)=oatunci
Tiparested
Sfarsitdaca
Sfarsitpentru
Stop
Program:

#include<iostream>
#include<conio.h>
usingnamespacestd;
intn,a,b,p,x,i;
intmain(){
cout<<"n=";cin>>n;
for(i=1;i<=n;i++)
if(n%i==0)
cout<<i<<"";
getch();
return0;}
68.secitescnnumere.Sasedeterminecatedintreeleapartinintervalului(a,b)undeasibsuntnr
intregi.
Algoritm:
Start
Citesten
P=0
Pentrui=1lan
Dacai>asaui<batunci
P++
Sfarsitdaca
Sfarsitpentru
TiparesteP
Stop
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
intn,maxd,x,i;
intmain(){

cout<<"n=";cin>>n;
maxd=0;
for(i=1;i<=n;i++)
{cout<<"x=";cin>>x;
while(x)
{if(x%10>maxd)
maxd=x%10;
x=x/10;}}
cout<<maxd;
getch();
return0;}
69.Secitescnnr.sasedeterminecatedintrenrcititeaucifreleegale.
Algoritm:
Start
Citesten
p=0;
Pentru(i=1lan;pas1)
Citestex
Daca(rest(n,10)=rest(cat(1/10)%10)atunci
p=p+1
x=cat(n,10)
tiparestesuntpnrcarerespectaconditia
sfarsitdaca
sfarsitpentru
stop
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
intn,x,p,i;
intmain(){
cout<<"n=";cin>>n;
p=0;
for(i=1;i<=n;i++)

{cout<<"x=";cin>>x;
if(x%10==(x/10)%10)
p=p+1;
x=x/10;}
cout<<"sunt"<<p<<"nrcarerespectaconditia";
getch();
return0;}

70.Secitescnnr.saseafisezetoatenrimparemaimicisauegalecu4
Algoritm:
start
citesten
pentru(k=1lan,pas1)
citestey
gasit=0;
dacarest(y,2)=0siy<4atunci
gasit=1;
dacagasit=1atunci
tipareste,,nrsunt:y;
sfarsitdaca
sfarsitpentru
stop
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
intn,y,k,gasit;
intmain(){
cout<<"n=";cin>>n;
for(k=1;k<=n;k++)
{cout<<"y=";cin>>y;
gasit=0;
if(y%2&&y<=4)

gasit=1;
if(gasit)
cout<<"nrsunt:"<<y<<"";}
getch();
return0;}
71.sasedeterminemediaaritmeticaadivizorilorpropriiaiunuinrnaturalncititdelatastatura
Algoritm:
start
citesten
s=o
d=0
pentru(i=2lan,pas1)
dacarest(n,i)=0atunci
s=s+i
d=d+1
tiparestes/d
sfarsitdaca
sfarsitpentru
stop
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
intn,d,s,i;
intmain(){
cout<<"n=";cin>>n;
s=0;
d=0;
for(i=2;i<n;i++)
{if(n%i==0)

{s+=i;
d++;}}
cout<<"mediaaritmeticaeste"<<s/d;
getch();
return0;}
72.Fiinddate2nrasib,saseafisazetoatenrprimedinintervalul[a,b]
Algoritm:
start
citestea,b
pentru(i=alab,pas1)
p=0
pentru((d=2lai,pas1)
dacarest(i,d)=0atunci
p=1
dacap=0atunci
tiparestei;
sfarsitdaca
sfarsitpentru
stop
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
inta,b,d,i,p;
intmain(){
cout<<"a=";cin>>a;
cout<<"b=";cin>>b;
for(i=a;i<=b;i++)
{p=0;
for(d=2;d<i;d++)

{if(i%d==0)
p=1;}
if(p==0)
cout<<i<<"";}
getch();
return0;}
73.Secitescnumerenaturalepanalaintalnireanumarului0.Saseafisezenumereleprime.
Algoritm:
Start
Citesten
Cattimpn!=0executa
Prim=1
Pentrui=2lanpas1
Dacarest(n,i)==0atunci
Prim=0
Sfarsitdaca
Dacaprim=1atunci
Tiparesten=
Sfarsitdaca
Sfarsitpentru
Citesten
Sfarsitcattimp
Stop
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
intprim,i,x,j,n;
intmain(){
cout<<"n=";cin>>n;
while(n!=0)
{prim=1;
for(i=2;i<n;i++)
if(n%i==0)
prim=0;
if(prim)
cout<<n<<"";
cout<<"n=";cin>>n;
}
getch();
return0;}
74.Secitescnumarenaturalpanalaintalnireaunuinumarnegativ.Saseafisezenumereleprime
citite.
Algoritm:
Start
Citesten
Cattimpn>=0executa

Prim=1
Pentrui=2lanpas1
Dacarest(n,i)==0atunci
Prim=0
Sfarsitdaca
Dacaprim=1atunci
Tiparesten=
Sfarsitdaca
Sfarsitpentru
Citesten
Sfarsitcattimp
Stop
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
intprim,i,x,j,n;
intmain(){
cout<<"n=";cin>>n;
while(n>=0)
{prim=1;
for(i=2;i<n;i++)
if(n%i==0)
prim=0;
if(prim)
cout<<n<<"";
cout<<"n=";cin>>n;
}
getch();
return0;}
75.Secitescnumareuiteasapanalaintalnireaunuinumarintregx.Saseafisezenumereleprime
citite.
Algoritm:
Start
Citesten,x
Cattimpn>xexecuta
Prim=1
Pentrui=2lanpas1
Dacarest(n,i)==0atunci
Prim=0
Sfarsitdaca
Dacaprim=1atunci
Tiparesten=
Sfarsitdaca
Sfarsitpentru
Citesten
Sfarsitcattimp
Stop
Program:
#include<iostream>
#include<conio.h>

usingnamespacestd;
intprim,i,x,j,n;
intmain(){
cout<<"n=";cin>>n;
cout<<x=;cin>>x;
while(n>x)
{prim=1;
for(i=2;i<n;i++)
if(n%i==0)
prim=0;
if(prim)
cout<<n<<"";
cout<<"n=";cin>>n;
}
getch();
return0;}
76.Secitescnumerenaturalepanalaintalnireaunuinumarintregk.Saseafisezemediaaritmeticaa
numerelorcititeprime.
Algoritm:
Start
Citesten,k
S=0
P=0
Cattimpn>kexecuta
Prim=1
Pentrui=2lanpas1
Dacarest(n,i)=0atunci
Prim=0
Sfarsitdaca
Dacaprim=1atunci
S=S+n
P=P+1
TiparestemediaaritmeticaesteS/P
Sfarsitdaca
Sfarsitpentru
Sfarsitcattimp
Stop
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
intprim,P,Si,x,j,n;
intmain(){
cout<<"n=";cin>>n;
cout<<k=;cin>>k;
S=0;
P=0;
while(n>k)
{prim=1;
for(i=2;i<n;i++)
if(n%i==0)

prim=0;
if(prim)
S=S+n;
P++;
cout<<S/P<<"";
cout<<"n=";cin>>n;
}
getch();
return0;}
85.Saseafisezeprintrunprogramtoatenr.dedouacifrecaresedividcusumasiprodusulcifrelorlui
Algoritm:
Start
S=0
P=0
Pentrui=10la99
S=cat(i.10)+rest(i,10)
P=cat(I,10)*rest(I,10)
Dacarest(I,s)=osirest(I,p)=0atunci
TiparesteI
Sf.daca
Sf.pentru
STOP
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
inti,s,p;
intmain(){
for(i=10;i<=99;i++)
{s=0;
p=0;
s=i/10+i%10;
p=i/10*i%10;
if(i%s==0&&i%p==0&&p&&s)
cout<<i<<endl;}
getch();
return0;}
86.Sedaunnumarnaturalp.Sasedeterminedacanr.contineinscrierealuisecventa15.
Algoritm:
START
Citestep
Gasit=0
Cattimpp>0executa
Dacarest(p,10)=5sirest(cat(p,10),10)=1atunci
Gasit=1
Sf.daca
P=cat(p,10)
Sf.cattimp
Dacagasit=1atunci
Tiparestesecventasegaseste
Altfel

Tiparestesecventanusegaseste
Sf.daca
STOP
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
intp,gasit;
intmain(){
cout<<"p=";cin>>p;
gasit=0;
while(p)
{if(p%100==15)
gasit=1;
p=p/10;}
if(gasit==1)
cout<<"nr.continesecventa15";
else
cout<<"nucontinesecventa15";
getch();
return0;}
87.Secitesteprintrunprogramnr.delatastaturapanalacitireavalori0.Secerecalculareasiafisarea
medieiaritmeticeapatratelornr.PoZitivecitite.
Algoritm:
START
Citestex
P=0
S=0
Cattimpx>0executa
Dacax>0atunci
S=s+x*x
P=p+1
Sf.daca
Sf.cattimp
Tiparestemediaaritmeticaestes/p
STOP
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
intx,s,p;
intmain(){
p=0;
s=0;
cout<<"x=";cin>>x;
while(x)
{if(x>0)
{
s=s+x*x;
p=p+1;
}

cout<<"x=";cin>>x;}
cout<<"mediaaritmeticaeste"<<(float)s/p;
getch();
return0;}
88.Unbancherareunseifcucifru.Pentruanuuitacifrulurcasalscriepeofoaiecodificatfiecare
cifrasafieinlocuitacudiferntadintrecifranouasicifrarespective.Bancherulsiaalesuncifru,
ajutatilsalcodificedupametodaluistiindcacifrulincepecuocifradiferitadenoua.Scrietiun
programcarepreiacifruldelatastaurasiafiseazacifrulcodificat.
Algoritm:
START
Citesten
P=0
Cattimpn>0executa
P=p*10+9rest(n,10)
N=cat(n,10)
Sf.cattimp
A=0
Cattimpp>0executa
A=a*10+rest(p,10)
P=cat(p,10)
Sf.cattimp
TiparestecifrulcodificatesteA
STOP
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
intn,p,a;
intmain(){
cout<<"n=";cin>>n;
p=0;
a=0;
while(n)
{p=p*10+9n%10;
n=n/10;}
while(p)
{a=a*10+p%10;
p=p/10;}
cout<<"cifrulcodateste"<<a;
getch();
return0;}
89.Secitescnnumere,sasenumerecatedintreeleaupdivizori,primele3cifreconsecutivein
ordinedescrescatoaresiultimele2cifresafieegale.
Algoritm:
START
Citesten,p,x
A=0
Pentrui=1lan
S=0
Pentruj=1lax
Dacarest(x,j)=0atunci

S=S+1
Sfarsitdaca
Sfarsitpentru
B=x
CattimpB>=1000executa
DacaS=Psicat(B,100)=rest(cat(B,10),10)sirest(cat(B,10),10=rest(B,10)+1si
rest(cat(x,10),10)=rest(x,10)atunci
A=A+1
TiparesteA
Sfarsitdaca
Sfarsitcattimp
STOP
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
intn,p.A,B,S,x,i,j;
intmain()
{cout<<"n=";cin>>n;
cout<<"p=";cin>>p;
A=0;
for(i=1;i<=n;i++)
{cout<<"x=";cin>>x;
S=0;
for(j=1;j<=x;j++)
if(x%j==0)
S=s+1;
B=x;
while(B>=1000)
B=B/10;
IF(S==p&&b/100==(B/10)%10+1&&(B/10)%10==B%10+1&&(x/10)%10==x%10)
A=A+1;
COUT<<"sunt"<<A<<"numerecarerespectaconditia";
getch();
return0;}
90.Incatezerouriseterminaunnumardemaxim9cifre,introdusdelatastatura?
Algoritm:
START
Citesten
Dacan>0atunci
x=n
Cattimprest(n,10)=0executa
P=P+1
n=cat(n,10)
tiparestex
sfarsitcattimp
sfarsitdaca
STOP
Program:
#include<iostream>
include<conio.h>

usingnamespacestd;
intn,P,x;
inymain()
{cout<<"n=";cin>>n;
if(n!=0)
x=n;
while(n%10==0)
{P++;
n=n/10;
cout<<"numarul"<<x<<"are"<<P<<"zerouri";
getch();
return0;}
91.Seintroduceunnumarnaturalncumaxim8cifre,nenulesidistincte,maimicica9.saseafiseze
cifrelenumaruluiinordinedescrescatoare.
Algoritm:
START
Citesten
Pentrui=8la0
Cattimpn>0executa
Dacarest(n,10)=Iatunci
Tiparesten
n=cat(n,10)
Sfarsitdaca
Sfarsitcattimp
Sfarsitpentru
STOP
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
intn,i;
intmain(){
cout<<"n=";cin>>n;
for(i=8;i>=0;i)
while(n)
{if(n%10==i)
cout<<n%10;
n=n\10;}
getch();
return0;}
92.Sedaunnumarintregdemaxim9cifre,saseafisezenumaruldeaparitiiafiecareicifre.
Algoritm:
START
Citesten
Cattimpn>0executa
Dacarest(n,10)=0atunci
a=a+1
Sfarsitdaca
Altfel
Dacarest(n,10)=1atunci
b=b+1

Sfarsitdaca
Altfel
Daca(rest(n,10)=2atunci
c=c+1
Sfarsitdaca
Altfel
Dacarest(n,10)=3atunci
d=d+1
Sfarsitdaca
Altfel
Dacarest(n,10)=4atunci
e=e+1
Sfarsitdaca
Altfel
Dacarest(n,10)=5atunci
f=f+1
Sfarsitdaca
Altfel
Dacarest(n,10)=6atunci
g=g+1
Sfarsitdaca
Altfel
Dacarest(n,10)=7atunci
h=h+1
Sfarsitdaca
Altfel
Dacarest(n,10)=8atunci
i=i+1
Sarsitdaca
n=rest(n,10)
Tiparestea
Tiparesteb
Tiparestec
Tiparested
Tiparestee
Tiparestef
Tiparesteg
Tiparesteh
Tiparestei
Sfarsitcattimp
stop
Program:
#include<iostream>
#include<conio.h>
usingnamaspacestd;
longn,a,b,c,d,e,f,g,r;
intmain(){
cout<<"n=";cin>>n;
while(n)
{if(n%10==0)
a+=1;

else
if(n%10==1)
b+=1;
else
if(n%10==2)
c+=1;
else
if(n%10==3)
d+=1;
else
if(n%10==4)
f+=1;
else
if(n%10==5)
if+=1;
else
if(n%10==6)
g+=1;
else
if(n%10==7)
h+=1;
else
if(n%10==8)
i+=1;
n=n/10;}
cout<<"cifra0aparede"<<a<<"ori";
cout<<"cifra1aparede"<<b<<"ori";
cout<<"cifra2aparede"<<c<<"ori";
cout<<"cifra3aparede"<<d<<"ori";
cout<<"cifra4aparede"<<e<<"ori";
cout<<"cifra5aparede"<<f<<"ori";
cout<<"cifra6aparede"<<g<<"ori";
cout<<"cifra7aparede"<<h<<"ori";
cout<<"cifra8aparede"<<i<<"ori";
getch();
return0;}
93.Afisaticatecifredistinctecontineunnumarnenul.
Algoritm:
START
Citesten
P=0
Pentrui=0la8
X=n
S=0
Cattimpx>0siS=0executa
Dacarest(x,10)=1atunci
S=1
X=cat(x,10)
Sfarsitdaca
Sfarsitcattimp
DacaS=1atunci

P=P+1
TiparesteP
Sfarsitpentru
STOP
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
intn,P,i,S,x;
intmain()
{cout<<"n=";cin>>n;
P=0;
for(i=0;i<=9;i++)
{x=n;
S=0;
while(x&&S==0)
{if(x%10==i)
S=1;
x=x/10}
if(S==1)
P=P+1;}
Cout<<"avem"<<P<<"cifredistincte";
getch();
returno;}
94.Sedaudouanumerenaturalea,bcumaximnouacifre.
a)Sasedeterminecifreledistinctecommunenumerelora,b.
b)Saseafisezenumerelecelemaimariformatedintoatecifreleluiasib.
Algoritm:

a)
START
Citestea,b
Pentrui=0la8
Gasit1=0
X=0
Cattimpx>0siGasit1=0executa
Dacarest(x,10)=Iatunci
Gasit1=1
Xcat(x,10)
Gasit2=0
X=b
Cattimpx>0siGasit2=0executa
Dacarest(x,10)=1atunci
Gasit2=1
X=cat(x,10)
DacaGasit1=1siGasit2=1atunci
Tiparestei
Sfarsitdaca
Sfarsitdaca
Sfarsitcattimp
Sfarsitdaca

Sfarsitcattimp
Sfarsitpentru
STOP

b)START
Citestea,b
S=0
Pentrui=9la0
Nr=0
X=a
Cattimpx>0executa
Dacarest(x,10)=Iatunci
Nr=Nr+1
X(rest(x,10)
Pentruk=1laNr
S=S*10+i
TiparesteS
Sfarsitpentru
Sfarsitdaca
Sfarsitcattimp
Sfarsitdaca
Sfarsitcattimp
Sfarsitpentru
STOP
Program:
A)
#include<iostream>
#include<conio.h>
usingnamespace.std;
inta,b,x,i,gasit1,gasit2;
intmain()
{cout<<"a=";cin>>a;
cout<<"b=";cin>>b;
{gasit1=0;
x=0
while(x&&gasit1==0)
{if(x%10==i)
gasit1=1
x=x/10}
gasit2=0;
x=b;
while(x&&gasit2==0)
{if(gasit1==1&&gasit2==1)
cout<<i<<"";}
getch();
return0;}

B)#include<iostream>
#include<conio.h>
usingnamespacestd;
intp,b,x,i,k,S,Nr;

intmain()
{cout<<"a=";cin>>a;
cout<<"b=";cin>>b;
for(i=9;i>=0;i+i1)
Nr=0;
x=a;
while(x)
{if(x%10==i)
Nr++;
x=x/10;
x=b;
while(x)
{if(x%10==i)
Nr++;
x=x/10;}
for(k=1;k<=Nr;k++)
S=S*10+I;}
cout<<"Nrobtinuteste<<S;
getch();
return0;}
95.Seintroducedouanumereasib,a>b<50000000.Saseafisezeultimacifraasumeituturor
numereloraflateintreasib.
Algoritm:
START
Citestea,b
P=0
Pentrui=alab
P=P+rest(i,10)
TiparesteP
Sfarsitpentru
STOP
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
inta,b,i,P;
intmain(){
cout<<"a=";cin>>a;
cout<<"b=";cin>>b;
for(i=a;i<=b;i++)
P=P+i%10;
cout<<"sumaeste"<<S;
getch();
return0;}
96.Sedaudouanumereavandaceleasinumeredecifre.Catecifretrebuiemodificatepentrua
transformaunnumarincelalalt?
Algoritm:
START
Citestea,b
Cattimpa>0sib>0executa
Dacarest(a,10)=rest(b,10)atunci

S=S+1
a=cat(a,10)
b=cat(b,10)
TiparesteS
Sfarsitdaca
Sfarsitcattimp
STOP
Program:
#include<iostream>
#include<conio.h>
usinhnamespacestd;
inta,b,S;
intmain(){
S=0;
cout<<"a=";cin>>a;
cout<<"b=";cin>>b;
while(a!=0&&b!=0)
{if(a%10!=b%10)
S=S+1;
a=a/10;
b=b/10;}
cout<<"trebuiefacute"<<S<<"modificari";
getch();
return0;}
97.Sedaudouanumerenenule.sasxeafisezec.m.m.d.csic.m.m.m.callor.
Algoritm:
START
CITESTEa,b
x=a
y=b
CATTIMPadiferitdebEXECUTA
DACAa>b
a=b
altfel
b=a
PENTRUi=1la456789099pas1
DACArest(i,x)=0siorest(i,y)=0atunci
TIPARESTEx=i
i=456789099
SFARSITDACA
SFARSITPENTRU
SFARSITDACA
SFARSITCATTIMP
TIPARESTE"c.m.m.d.calcelordouanumereeste",a"c.m.m.m.calcelordouanumereeste",x
STOP.
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
inta,b,x,y,i;
intmain(){

cout<<"a=";cin>>a;
cout<<"b=";cin>>b;
x=a;
y=b;
while(a!=b)
{if(a>b)
a=b;
else
b=a;}
for(i=1;i<456789099;i++)
{if(i%x==0&&i%y==0)
{x=i;
i=456789099;}}
cout<<"c.m.m.d.calcelordouanumereeste"<<a<<endl;
cout<<"c.m.m.m.calcelormdouanumereeste"<<x<<endl;
getch();
return0;}
98.Sesaunumitorulsinumaratoruluneifractii.Sasesimplifice,dacasepoatesisaseafisezefractia
simplificata.
Algoritm:
START
CITESTEx,y;
a=x
b=y
CATTIMPadiferitdebEXECUTA
DACAa>bATUNCI
TIPARESTE
a+=b
ALTFEL
b+=a
SFARSITDACA
DACAcat(x,a)=xsicat(y,a)=yATUNCI
TIPARESTE"fractiaesteireductibila"
ALTFEL
TIPARESTE"fractiasimplificataeste<<cat(x,a)<<"cat"<<cat(y,a)
SFARSITDACA
SFARSITCATTIMP
STOP.
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
longa,b,x,y;
intmain(){
cout<<"x=";cin>>x;
cout<<"y=";cin>>y;
a=x;
b=y;
while(a!=b)
{if(a>b)
a+=b;

else
b+=a;}
if(x/a==x&&y/a==y)
cout<<"fractiaesteireductibila"
else
cout<<"fractiasimplificataeste"<<x/a<<"/"<<y/a;
getch();
return0;}
99.Sedautreinumere.Determinatisiafisatic.m.m.d.callor.
Algoritm:
START
CITESTEa,b,c
CATTIMPadiferitdebEXECUTA
DACAa>bATUNCI
TIPARESTEa=b
altfel
TIPARESTEb=a
CATTIMPadiferitdecEXECUTA
DACAa>cATUNCI
TIPARESTEa=c
ALTFEL
TIPARESTEc=a
SFARSITDACA
SFARSITCATTIMP
SFARSITDACA
SFARSITCATTIMP
TIPARESTE"c.m.m.d.calcelortreinumereeste",a
STOP.
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
inta,b,c;
intmain(){
cout<<"a=";cin>>a;
cout<<"b=";cin>>b;
cout<<"c=";cin>>c;
while(a!=b)
{if(a>b)
a=b;
else
b=a;}
while(a!=c)
{if(a>c)
a=c;
else
c=a;}
cout<<"celmaimaredivizorcomunalcelortreinumereeste"<<a<<endl;
getch();
return0;}
100.Sesanumaruln.Saseafisezetoatenumerelemaimicicaelsiprimecuel.

Algoritm:
START
CITESTEi,n,a,b;
PENTRUi=1lanpas1EXECUTA
a=i
b=n
CATTIMPadiferitdebEXECUTA
DACAa>bATUNCI
TIPARESTE
a+=b
ALTFEL
b+=a
DACAa=1ATUNCI
TIPARESTE<<i<<
SFARSITDACA
SFARSITDACA
SFARSITCATTIMP
SFARSITPENTRU
STOP.
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
longa,b,n,i;
intmain(){
cout<<"n=";cin>>n;
cout<<"numerelesunt";
for(i=1;i<n;i++)
{a=i;
b=n;
while(a!=b)
{if(a>b)
a=b;
else
b=a;}
if(a==1)
cout<<i<<"";}
getch();
return0;}
101.Sedaunnumar.Sasescriedacasepoatecasumadedouanumereimpare.
Algoritm:
Start
Citesten,i
Dacarest(n,2)=0atunci
Pentrui=1lanpas2
Tiparesten=ni+i
Altfel
TiparesteNusepoatescriecasumadedouanumereimpare
Sfarsitpentru
Sfarsitdaca
Stop

Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
intn,i;
intmain(){
cout<<"n=";cin>>n;
if(n%2==0){
for(i=1;i<n;i=i+2)
cout<<n<<"="<<ni<<"+"<<i;}
else
cout<<"nusepoatescriecasumadedouanumereimpare";
getch();
return0;}
102.Sedaunnumar.Sasescrie,dacaesteposibil,casumadedouanumereconsecutive.
Algoritm:
Start
Citesten
Dacarest(n,2)!=0atunci
Tiparesten=cat((n1),2)+cat((n+1),2)
Altfel
TiparesteNusepoatescriecasumadedouanumereconsecutive
Sfarsitdaca
Stop.
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
intn;
intmain(){
cout<<"n=";cin>>n;
if(n%2!=0)
cout<<n<<"n"<<"="<<(n1)/2<<"+"<<(n+1)/2;
else
cout<<"nusepoatescriecasisumadedouanumereconsecutive";
getch();
return0;}
103.Saseinlocuiascaliterelecucifreinscadereaurmatoare:
abcbe
edab
____
ebce
Algoritm:
Start
Citestea,b,c,d,e,n1,n2,dif
Pentru(a=1la9pas1)
Pentru(b=0la9pas1)
Pentru(c=0la9pas1)
Pentru(d=0la9pas1)
Pentru(e=0la9pas1)
n1=a*10000+b*1000+c*100+b*10+e

n2=e*1000+d*100+a*10+b
Dif=e*1000+b*100+c*10+e
Sfarsitpentru
Sfarsitpentru
Sfarsitpentru
Sfarsitpentru
Sfarsitpentru
Dacan1n2=difatunci
TiparesteDif=n1n2
Sfarsitdaca
Stop
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
inta,b,c,d,e,n1,n2,Dif;
intmain(){
for(a=1;a<=9;a++)
for(b=0;b<=9;b++)
for(c=0;c<=9;c++)
for(d=0;d<=9;d++)
for(e=1;e<=0;e++)
{n1=a*10000+b*1000+c*100+b*10+e;
n2=e*1000+d*100+a*10+b;
Dif=e*1000+b*100+c*10+e;
if(n1n2==Dif)
cout<<n1<<""<<endl<<n2<<endl<<""<<endl<<Dif<<endl;}
getch();
return0;}
104.Sasefacaconversiaunuinumarnaturalndinbaza10inbaza2.
Algoritm:
Start
Citesten,S,P,x
x=n
S=7
Cattimpn!=0executa
S=S*10+rest(n,2)
n=cat(n,2)
Sfarsitcattimp
P=0
CattimpS!=0executa
P=P*10+rest(S,10)
S=cat(S,10)
Sfarsitcattimp
Tiparestenumarul,x,este,cat(P,10),inbaza2.
Sfarsitdaca
Stop.
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;

intn,S,P,x;
intmain(){
cout<<"n=";cin>>n;
x=n;
S=7;
while(n)
{S=S*10+n%2;
n=n/2;}
P=0;
while(S)
{P=P*10+S%10;
S=S/10;}
cout<<"numarul"<<n<<"este"<<P/10<<"inbaza2";
getch();
return0;}
105.Sasefacaconversiaunuinumarnaturalndinbaza10inbaza8.
Algoritm:
start
citesten
x=n
s=3
cattimpn=!0executa
s=s*10+rest(n,8)
n=cat(n,8)
sfarsitcattimp
p=0
cattimps=!0executa
p=p*10+rest(s,10)
s=cat(s,10)
sfarsitcattimp
p=cat(p,10)
tiparestep
stop
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
longn,s,p,x;
intmain(){
cout<<"n=";cin>>n;
x=n;
s=3;
while(n)
{s=s*10+n%8;
n=n/8;}
p=0;
while(s)
{p=p*10+s%10;
s=s/10;}
cout<<"numarul"<<x<<"este"<<p/10<<"inbaza8";
getch();

return0;}
106.Secitesteunsirdenumereintregi,sasedeterminecatedintreelementecontincifra3.
Algoritm:
start
citesten
s=0
pentrui=0lan1executa
citestea[i]
sfarsitpentru
cattimpa[i]=!0executa
dacarest(a[i],10)=3atunci
s=s+1
a[i]=cat(a[i],10)
sfarsitdaca
sfarsitcattimp
tiparestes
stop
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
intn,i,a[50],s;
intmain(){
cout<<"n=";cin>>n;
for(i=0;i<n;i++)
{cout<<"a["<<i<<"]=";
cin>>a[i];}
cout<<"sirulcititeste"<<endl;
for(i=0;i<n;i++)
cout<<a[i]<<"";
s=0;
for(i=0;i<n;i++)
while(a[i]){
if(a[i]%10==3)
s=s+1;
a[i]=a[i]/10;}
cout<<"sunt"<<s<<"numerecarecontincifra3";
getch();
return0;}
107.Sasefacaconversiaunuinumarnaturalndinbaza10introbazab,2<=b<10.
Algoritm:
start
citesten,b
x=n
s=1
cattimpn=!0executa
s=s*10+rest(n,b)
n=cat(n,b)
sfarsitcattimp
p=0
cattimps=!0executa

p=p*10+rest(s,10)
s=cat(s,10)
sfarsitcattimp
p=cat(p,10)
tiparestep
stop
Program
#include<iostream>
#include<conio.h>
usingnamespacestd;
longn,b,s,p,x;
intmain(){
cout<<"n=";cin>>n;
cout<<"b=";cin>>b;
x=n;
s=1;
while(n)
{s=s*10+n%b;
n=n/b;}
p=0;
while(s)
{p=p*10+s%10;
s=s/10;}
p=p/10;
cout<<"numarul"<<x<<"este"<<p<<"inbaza"<<b;
getch();
return0;}
108.Secitesteunsirdenumereintregi,sasedeterminecatedintreelementeauunnumarparde
cifre.
Algoritm:
start
citesten
p=0
pentrui=0lan1executa
citestea[i]
sfarsitpentru
cattimpa[i]=!0executa
s=s+1
a[i]=cat(a[i],10)
sfarsitcattimp
dacarest(s,2)=0atunci
p=p+1
sfarsitdaca
tiparestep
stop
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
intn,i,a[50],s,p;
intmain(){

cout<<"n=";cin>>n;
for(i=0;i<n;i++)
{cout<<"a["<<i<<"]=";
cin>>a[i];}
cout<<"sirulcititeste"<<endl;
for(i=0;i<n;i++)
cout<<a[i]<<"";
p=0;
for(i=0;i<n;i++){
s=0;
while(a[i]){
s=s+1;
a[i]=a[i]/10;}
if(s%2==0)
p=p+1;}
cout<<"sunt"<<p<<"elementecareauunnumartpardecifre";
getch();
return0;}
109.Sasefacaconversiaunuinumarnaturalndinbaza2inbaza10;
Algoritm:
START
Citesten
nr=0
x=n
cattimpx#0executa
x=cat(x,10)
nr=nr+1
sfarsitcattimp
s=0
pentrui=0lan
p=1
pentruj=1lai
p=p*2
s=s+rest(n,10)*p
n=cat(n,10)
sfarsitpentru
sfarsitpentru

Tiparesetenumaruleste,s
STOP
Program:
#include<iostream>
#include<conio.h>
Usingnamespacestd;
longn,nr,x,i,j;
ints,p;
intmain(){
cout<<"n=";cin>>n;
nr=0;
x=n;
while(x)
{x=x/10;
nr=nr+1;}
s=0;
for(i=0;i<n;i++)
{p=1;
for(j=1;j<=i;j++)
p=p*2;
s=s+(n%10)*p;
n=n/10;}
cout<<"numaruleste"<<s;
getch();
return0;}
110.Sasefacaconversiaunuinumarnaturalndinbaza8inbaza10:
Algoritm:
START
Citesten
nr=0

x=n
cattimpx#0executa
x=cat(x,10)
nr=nr+1
sfarsitcattimp
s=0
pentrui=0lan
p=1
pentruj=1lai
p=p*8
s=s+rest(n,10)*p
n=cat(n,10)
sfarsitpentru
sfarsitpentru
Tiparesetenumaruleste,s
STOP
Program:
#include<iostream>
#include<conio.h>
Usingnamespacestd;
longn,nr,x,i,j;
ints,p;
intmain(){
cout<<"n=";cin>>n;
nr=0;
x=n;
while(x)
{x=x/10;
nr=nr+1;}
s=0;

for(i=0;i<n;i++)
{p=1;
for(j=1;j<=i;j++)
p=p*8;
s=s+(n%10)*p;
n=n/10;}
cout<<"numaruleste"<<s;
getch();
return0;}
111.Sasefacaconversiaunuinumarnaturalndinbazab<10inbaza10:
Algoritm:
START
Citesten
nr=0
x=n
cattimpx#0executa
x=cat(x,10)
nr=nr+1
sfarsitcattimp
s=0
pentrui=0lan
p=1
pentruj=1lai
p=p*b
s=s+rest(n,10)*p
n=cat(n,10)
sfarsitpentru
sfarsitpentru
Tiparesetenumaruleste,s
STOP

Program:
#include<iostream>
#include<conio.h>
Usingnamespacestd;
longn,nr,x,i,j,b;
ints,p;
intmain(){
cout<<"n=";cin>>n;
nr=0;
x=n;
while(x)
{x=x/10;
nr=nr+1;}
s=0;
for(i=0;i<n;i++)
{p=1;
for(j=1;j<=i;j++)
p=p*b;
s=s+(n%10)*p;
n=n/10;}
cout<<"numaruleste"<<s;
getch();
return0;}
112.Sasescrieunprogramcarecalculeazaprodusulannumereintregidatedelatastatura.
Algoritm:
Start
Citesten
Pentrui=1lanpas1
Citestex
S=S*n

Sfarsitpentru
Tiparesteprodusuleste,S
Stop
Program:
#include<iostream>
#include<conio.h>
Usingnamespacestd;
intn,x,i,S;
intmain(){
cout<<"x=";cin>>x;
S=1;
for(i=0;i<x;i++)
{cout<<"n=";cin>>n;
S=S*n;
}
cout<<"produsuleste"<<S;
getch();
return0;}
113.Sasefacaconversiaunuinumarnaturaldintrobazabinbaza10.(2<=b;b!=10)
Algoritm:
Start
Citesten,b;
x=n;
Dacab>=2sib<=9atunci
S=0;
Cattimpx0executa
x=cat(x,10);
S=S+1;
Sfarsitcattimp
P=0;
Pentrui=0laS1pas1
A=1;
Pentruj=1laIpas1
A=A*b;
P=P+rest(n,10)*A;
n=cat(n,10)
Tiparestenumaruleste,P;
Sfarsitpentru

Sfarsitpentru
Altfel
Tiparestebazanuestevalida
Sfarsitdaca
Stop
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
longn,b,S,P,x,A,j,i;
intmain()
{
cout<<"n=";cin>>n;
x=n;
cout<<"b";cin>>b;
if(b>=2&&b<=9)
{S=0;
while(x)
{x=x/10;
S=S+1;}
P=0;
for(i=0;i<S;i++)
{A=1;
for(j=1;j<=i;j++)
A=A*b;
P=P+(n%10)*A;
n=n/10;
cout<<"numaruleste"<<P;}}
else
cout<<"bazanuestevalida";
getch();
return0;}

114.Sasefacaconversiaunuinumardinbaza2inbaza10.
Algoritm:
Start
Citesten
nr=0
x=n;
Cattimpx0executa
x=cat(x,10)
nr=nr+1
Sfarsitcattimp
S=0;
Pentrui=0lanr1pas1
P=1;
Pentruj=1laipas1
P=P*2
S=S+rest(n,10)*P
n=cat(n,10)
Sfarsitpentru

Sfarsitpentru
Tiparestenumaruleste,S
Stop
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
longn,x,S,P,i,j,nr;
intmain()
{
cout<<"n=";cin>>n;
nr=0;
x=n;
while(x)
{x=x/10;
nr=nr+1;}
S=0;
for(i=0;i<nr;i++)
P=1;
for(j=1;j<=i;j++)
{P=P*2;
S=S+(n%10)*P;
n=n/10;}
cout<<"numaruleste"<<S;
getch();
return0;
}
115.Saseafisezecifrelepatrateperfectealeunuinumarnsinumaruldeaparitiialeacestoraprintre
cifreleluin.
Algoritm:
Start
Citesten
A=0;
B=0;
C=0;
D=0;
Cattimpn0executa
Dacarest(n,10)=0atunci
A=A+1;
Altfel
Dacarest(n,10)=1atunci
B=B+1;
Altfel
Dacarest(n,10)=4atunci
C=C+1;
Altfel
Dacarest(n,10)=9atunci
D=D+1;
n=cat(n,10)
Sfarsitdaca
Sfarsitdaca

Sfarsitdaca
Sfarsitdaca
DacaA0atunci
Tiparestecifra0sagasitde,A,ori
Sfarsitdaca
DacaB0atunci
Tiparestecifra1sagasitde,B,ori
Sfarsitdaca
DacaC0atunci
Tiparestecifra4sagasitde,C,ori
Sfarsitdaca
DacaD0atunci
Tiparestecifra9sagasitde,D,ori
Sfarsitdaca
DacaA+B+C+D=0atunci
Tiparestenumarulnucontinepatrateperfecte
Sfarsitdaca
Sfarsitcattimp
Stop
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
intn,A,B,C,D;
intmain()
{
cout<<"n=";cin>>n;
A=0;
B=0;
C=0;
D=0;
while(n)
{if(n%10==0)
A++;
else
if(n%10==1)
B++;
else
if(n%10==4)
C++;
else
if(n%10==9)
D++;
n=n/10;}
if(A!=0)
cout<<"cifra0sagasitde"<<A<<"ori";
if(B!=0)
cout<<"cifra1sagasitde"<<B<<"ori";
if(C!=0)
cout<<"cifra4sagasitde"<<C<<"ori";
if(D!=0)

cout<<"cifra9sagasitde"<<D<<"ori";
if(A+B+C+D==0)
cout<<"numarulnucontinecifrepatrateperfecte";
getch();
return0;
}
116.Sasecauteocifradataprintrecifrelenumaruluinaturalnsisasedeterminenumaruldeaparitii
alecifreiprintrecifreleluin.
Algoritm:
Start
Citesten,x
S=0;
Cattimpn0executa
Dacarest(n,10)=xatunci
S=S+1;
n=cat(n,10)
Sfarsitdaca
Sfarsitcattimp
DacaS0atunci
Tiparestecifra,x,sagasitde,S,ori
Altfel
Tiparestecifra,x,nusegasesteinnumar
Sfarsitdaca
Stop
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
intn,S,x;
intmain()
{cout<<"n=";cin>>n;
cout<<"x=";cin>>x;
S=0;
while(n)
{if(n%10==x)
S++;
n=n/10;}
if(S!=0)
cout<<"cifra"<<x<<"sagasitde"<<S<<"ori";
else
cout<<"cifra"<<x<<"nuseaflainnumar";
getch();
return0;
}
117.Sasedecidadacasumacifrelornr.naturalnnenulestesaununr.prim.
Algoritm:
start
citesten
s=0
cattimpn>0executa
s=s+rest(n,10)

n=cat(n,10)
sfarsitcattimp
prim=1
pentrui=2lan
dacarest(n,i)=0
prim=0;
sfarsitdaca
sfarsitpentru
dacaprim=1
tipareste"sumacifrelorluinesteunnumarprim"
altfel
tipareste"sumacifrelorluinnuesteunnumarprim"
sfarsitdaca
stop
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
intn,i,s,p;
intmain(){
cout<<"n=";cin>>n;
while(n)
{s=s+n%10;
n=n/10;}
for(i=1;i<s;i++)
{if(n%i==0)
p=p+1;}
if(p==1)
cout<<"sumaestenrprim";
else
cout<<"sumanuestenrprim";
getch();
return0;}
118.Secitesteunnr.Sasenumerecatidivizoriprimicontinenumarul.
Algoritm:
start
citesten
pentrui=1lan
dacarest(n,i)=0atunci
prim=1
pentruj=2lai
dacarest(i,j)=0atunci
prim=0
sfarsitdaca
sfarsitpentru
dacaprim=1atunci
tiparestei
sfarsitdaca
sfarsitpentru
stop
Program:

#include<iostream>
#include<conio.h>
usingnamespacestd;
intn,s,i,j,prim;
intmain()
{cout<<"n=";cin>>n;
s=0;
for(i=1;i<=n;i++)
if(n%i==0)
{prim=1;
for(j=2;j<i;j++)
if(i%j==0)
prim=0;
if(prim==1)
s=s+1;}
cout<<"avem"<<s<<"divizoriprimi";
getch();
return0;}
119.Secitesteunnr.Sasenumerecatecifrecontinenr.cuprinseinintervalulformatdintreprima
cifrasiultimacifra.
Algoritm:
start
citesten
s=0
x=n
dacan>=10atunci
cattimpx>=10executa
x=cat(x,10)
sfarsitcattimp
y=rest(n,10)
cattimpn!=0executa
dacarest(n,10)>=xsirest(n,10)<=ysaurest(n,10)>=ysirest(n,10)<=xatunci
s=s+1
n=cat(n,10)
sfarsitcattimp
sfarsitdaca
tipareste"nrcontine"s"cifreininterval"
stop
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
intn,s,x,y;
intmain()
{cout<<"n=";cin>>n;
s=0;
x=n;
if(n>=10)
{while(x>=10)
x=x/10;
y=n%10;

while(n)
{if(n%10>=x&&n%10<=y||n%10>=y&&n%10<=x)
s=s+1;
n=n/10;}
cout<<"nrcontine"<<s<<"cifreininterval";
getch();
return0;}}
120.Secitesteunnr.Sasedeterminecelmaimicnr.caresepoateformacucifrelesale.Cifrelenr.
suntpozitive.
Algoritm:
start
citesten
x=0
pentrui=1la9
s=0
y=n
cattimpy!=0executa
dacarest(y,10)=iatunci
s=s+1
sfarsitdaca
y=cat(y,10)
sfarsitcattimp
pentruj=1j<=s
x=x*10+i
sfarsitpentru
sfarsitpentru
tipareste"nrformateste"x;
stop
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
longn,x,s,i,y,j;
intmain(){
cout<<"n=";cin>>n;
x=0;
for(i=1;i<=9;i++)
{s=0;
y=n;
while(y)
{if(y%10==i)
s=s+1;
y=y/10;}
for(j=1;j<=s;j++)
x=x*10+i;}
cout<<"nrformateste"<<x;
getch();
return0;}
121.Secitescdouanumere.Sasedeterminecaredintreceledouanumereareciframaimaredepe
pozitiapara.
Algoritm:

START
Citestea,b
maxa=0
maxb=0
x=a
y=b
a=ct(a,10)
Cttimpa!=0executa
Dacarest(a,10)>maxaatunci
maxa=rest(a,10)
Sfarsutdaca
a=ct(a,100)
Sfarsitcattimp
b=cat(b,10)
Cattimpb!=0executa
Dacarest(b,10)>maxbatunci
maxb=rest(b,10)
Sfarsitdaca
b=ct(b,100)
Sfarsitcattimp
Dacamaxa>maxbatunci
Tiparestecifraceamaimareocontine,x,sieste,maxa
Altfel
Tiparestecifraceamaimareocontine,y,sieste,maxb
Sfarsitdaca
STOP
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
longa,b,maxa,maxb,x,y;
intmain(){
cout<<"a=";cin>>a;
cout<<"b=";cin>>b;
maxa=0;
x=a;
y=b;
maxb=0;
a=a/10;
while(a)
{if((a%10)>maxa)
maxa=a%10;
a=a/100;}
b=b/10;
while(b)
{if((b%10)>maxb)
maxb=b%10;
b=b/100;}
if(maxa>maxb)
cout<<"cifraceamaimareocontine"<<x<<"sieste"<<maxa;
else

cout<<"cifraceamaimareocontine"<<y<<"sieste"<<maxb;
getch();
return0;}
122.Secitesctreinumere.Sasedeterminecifrelcommunecelortreinumere.
Algoritm:
START
Citestea,b,c
gasita=0
gasitb=0
gasitc=0
x=a
y=b
z=c
Pentrui=0la9executa
Cattimpx!=0executa
Dacarest(x,10)=iatunci
gasita=1
Sfarsitdaca
x=ct(x,10)
Sfarsitcattimp
Cattimpy!=0executa
Dacarest(y,10)=iatunci
gasitb=1
Sfarsitdaca
y=ct(y,10)
Sfarsitcattimp
Cattimpz!=0executa
Dacarest(z,10)=iatunci
gasitc=1
Sfarsitdaca
z=ct(z,10)
Sfarsitcattimp
Sfarsitpentru
Dacagasita*gasitb*gasitc*!=0atunci
Tiparestecifracomunaeste,i
Sfarsitdaca
STOP
123.Secitesteunnumar.Sasedeterminetoatemodurileposibileincaresepoatescrienumarulca
sumadepatrunumereconsecutive.
Algoritm:
START
Citesten
gasit=0
x=n
Pentrux=1lax<n/4executa
Dacax+(x+1)+(x+2)+(x+3)=natunci
gasit=1
Tiparesten,=,x,+,x+1,+,x+2,+,x+3
Sfarsitdaca
Dacagasit=0atunci
Tiparestenumarulnusepotescriecasumadepatrunumereconsecutive

Sfarsitdaca
Sfarsitpentru
STOP.
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
longx,n,gasit;
intmain(){
cout<<"n=";cin>>n;
gasit=0;
for(x=1;x<n/4;x++)
if(x+(x+1)+(x+2)+(x+3)==n)
{gasit=1;
cout<<n<<"="<<x<<"+"<<x+1<<"+"<<x+2<<"+"<<x+3;}
if(gasit==0)
cout<<"numarulnusepoatescriecasumadepatrunumereconsecutive";
getch();
return0;}
124.Secitestetreinumere.Sasedeterminecaredintreceletreinumerecontinocifracareserepeta
detreiori.
Algoritm:
START
Citestea,b,c
gasita=0
gasitb=0
gasitc=0
Pentrui=0la9executa
x=a
y=b
z=c
nria=0
Cattimpx!=0executa
Dacarest(x,10)=iatunci
nria=nria+1
Sfarsitdaca
x=ct(x,10)
Sfrasitcattimp
Dacanria=3atunci
Tiparestei,aparedetreioriin,a
gasita=1
Sfarsitdaca
nrib=0
Cattimpy!=0executa
Dacarest(y,10)=iatunci
nrib=nrib+1
Sfarsitdaca
y=ct(y,10)
Sfrasitcattimp
Dacanrib=3atunci
Tiparestei,aparedetreioriin,b

gasitb=1
Sfarsitdaca
nric=0
Cattimpz!=0executa
Dacarest(z,10)=iatunci
nric=nric+1
Sfarsitdaca
z=ct(z,10)
Sfrasitcattimp
Dacanric=3atunci
Tiparestei,aparedetreioriin,c
gasitc=1
Sfarsitdaca
Dacagasita=0sigasitb=0sigasitc=0atunci
Tiparestenusagasitniciocifradetreiori
Sfarsitdaca
STOP
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
longa,b,c,i,x,y,z,nria,nrib,nric,gasita,gasitb,gasitc;
intmain(){
cout<<"a=";cin>>a;
cout<<"b=";cin>>b;
cout<<"c=";cin>>c;
gasita=0;
gasitb=0;
gasitc=0;
for(i=0;i<=9;i++)
{x=a;
y=b;
z=c;
nria=0;
while(x)
{if(x%10==i)
nria++;
x=x/10;}
if(nria==3)
cout<<i<<"aparede3oriin"<<a;
gasita=1;}
nrib=0;
while(y)
{if(y%10==i)
nrib++;
y=y/10;}
if(nrib==3)
{cout<<i<<"aparede3oriin"<<b;
gasitb=1;}
nric=0;
while(z)

{if(z%10==i)
nric++;
z=z/10;}
if(nric==3)
{cout<<i<<"aparede3oriin"<<c;
gasitc=1;}
if(gasita==0&&gasitb==0&&gasitc==0)
cout<<"nusagasitniciocifrade3ori";
getch();
return0;}
125.Secitescnnumere.Ssedeterminectedinnumerelerespectiveauoglindaparinumarulde
divizoriimpar.
Algoritm:
START
Citeten,s,i,y,x,p,j;
s=0
Pentrui=1pnlan
y=x;
p=0;
Cttimpy>=10execut
y=ct(y,10)
Pentruj=1pnlax
Dacrest(x,j)=0atunci
p=p+1;
Dacrest(y,2)=0irest(p,2)!=0
s=s+1;
Sfritdaca
Sfritdaca
Sfritpentru
Sfritcttimp
Sfritpentru
Tipretesnumereleauoglindaparinumruldedivizoriimpar
STOP
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
longn,s,i,y,x,p,j;
intmain(){
cout<<"n=";cin>>n;
s=0;
for(i=1;i<=n;i++)
{cout<<"x=";cin>>x;
y=x;
p=0;
while(y>=10)
y=y/10;
for(j=1;j<=x;j++)
if(x%j==0)
p=p+1;
if(y%2==0&&p%2!=0)

s=s+1;}
cout<<s<<"numereleauoglindaparasinumaruldedivizoriimpar";
getch();
return0;}
126.Secitescnnumere.Ssedeterminectedintreeleaucifrelenordinecresctoareioglindalor
esteunnumrprim.
Algoritm:
START
Citeten,s,i,x,cresc,a,p,prim,j;
s=0;
Pentrui=1lan
cresc=1;
a=x;
Cttimpa!=0icresc!=0execut
Dacrest(a,10;rest(ct(a,10),10)atunci
cresc=1;
Sfritdac
a=ct(a,10)
Sfritcttimp
p=0;
Cttimpx!=0execut
p=p*10+rest(x,10)
x=ct(x,10)
Sfritcttimp
prim=1;
Pentruj=2lap
Dacrest(p,j)=0
prim=0;
Daccresc*prim=1atunci
s=s+1;
Sfritdac
Sfritdac
Sfritpentru
Sfritpentru
Tipretesuntsnumerecarerespectcondiia
STOP
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
longn,s,i,x,cresc,a,p,prim,j;
intmain(){
cout<<"n=";cin>>n;
s=0;
for(i=1;i<=n;i++)
{cout<<"x=";cin>>x;
cresc=1;
a=x;
while(a&&cresc)
{if(a%10<(a/10)%10)
cresc=0;

a=a/10;}
p=0;
while(x)
{p=p*10+x%10;
x=x/10;}
prim=1;
for(j=2;j<p;j++)
if(p%j==0)
prim=0;
if(cresc*prim==1)
s++;}
cout<<"sunt"<<s<<"numerecarerespectaconditia";
getch();
return0;}
127.Sseafiezecteelementepozitiveinegativeavemnir.
Algoritm:
START
Citetea[50],n,i,neg,poz,zer;
Pentrui=0lan1
Citetea[i]
Sfritpentru
Tipreteirulcititeste
Pentrui=0lan
Tipretea[i]
Sfritpentru
neg=0;
poz=0;
zer=0;
Pentrui=0lan
Daca[i]>0atunci
poz=poz+1;
Altfel
Daca[i]<0atunci
neg=neg+1;
Altfel
zer=zer+1;
Sfritdac
Sfritdac
Sfritpentru
Tipretepozitivesuntpoz,negativesuntneg,egalecuzerosuntzer;
STOP
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
inta[50],n,i,neg,poz,zer;
intmain(){
cout<<"n=";cin>>n;
for(i=0;i<n;i++)
{cout<<"a["<<i<<"]=";
cin>>a[i];}

cout<<"sirulcititeste"<<endl;
for(i=0;i<n;i++)
cout<<a[i]<<"";
neg=0;
poz=0;
zer=0;
for(i=0;i<n;i++)
{if(a[i]>0)
poz=poz+1;
else
if(a[i]<0)
neg=neg+1;
else
zer=zer+1;}
cout<<"pozitive"<<poz<<"negative"<<neg<<"egalecuzero"<<zer;
getch();
return0;}
128.Seciteteunirdenumerentregi.Ssedeterminectedintreelesuntpare,impareidivizibile
cu3.
Algoritm:
START
Citetea[50],n,i,neg,poz,zer;
Pentrui=0lan1
Citetea[i]
Sfritpentru
Tipreteirulcititeste
Pentrui=0lan
Tipretea[i]
Sfritpentru
par=0;
impar=0;
d3=0;
Pentrui=0lan
Dacrest(a[i],2)=0atunci
par=par+1;
Altfel
impar=impar+1;
Dacrest(a[i],3)=0atunci
d3=d3+1;
Sfritdac
Sfritdac
Sfritpentru
Sfritpentru
Tipretenumereparesuntpare,imparesuntimparesidivizibilecu3suntd3
STOP
Program:
#include<iostream>
#include<conio.h>
usingnamespacestd;
inta[50],n,i,par,impar,d3;
intmain(){

cout<<"n=";cin>>n;
for(i=0;i<n;i++)
{cout<<"a["<<i<<"]=";
cin>>a[i];}
cout<<"sirulcititeste"<<endl;
for(i=0;i<n;i++)
cout<<a[i]<<"";
par=0;
impar=0;
d3=0;
for(i=0;i<n;i++)
{if(a[i]%2==0)
par=par+1;
else
impar=impar+1;
if(a[i]%3==0)
d3=d3+1;}
cout<<"pare"<<par<<"impare"<<impar<<"sidivizibilecutrei"<<d3;
getch();
return0;}