REZOLVARI SUBIECTE C++
#include<fstream.h>
#include<conio.h>
#include<iostream.h>
struct lista;
ofstream f("date.out");
int prim(int n)
void interval(int &a,int&b)
lista *creare(int n)
i++;}
l1->adr=NULL;
return p;
lista *sterg(lista *p,int li,int ls)
a=p;
while(a->adr !=NULL)
if(a->adr->inf>=li && a->adr->inf<=ls)
else a=a->adr;
return p;
void main()
while (n<1 || n>1000);
//se creaza lista ce va contine n numere prime
p=creare(n);
l=p;
while (l!=NULL)
cout<<"\na=";cin>>a;
cout<<"b=";cin>>b;
//se ordoneaza a si b astfel incat a<b
interval (a,b);
//se elimina din lista numerele care apartin intervalului [a,b]
p=sterg(p,a,b);
//se scriu elementele listei
l=p;
while (l!=NULL)
f.close();
#include<math.h>
#include<conio.h>
#include<fstream.h>
ifstream f("date.in");
int n, v[20], c, cifre[10];
void minim_maxim(int&min,int&max)
int nr_patr_perf()
void ordonare_cifre()
void main()
while(max!=0)
ordonare_cifre();
for(i=1;i<=c;i++) cout<<cifre[i];
cout<<endl<<"tabloul are"<<nr_patr_perf()<<"patrate perfecte";
#include<fstream.h>
#include<conio.h>
struct lista;
ofstream f("date.out");
int palindrom(int x)
if(x==s) return 1;
else return 0;}
lista *inserare(lista *p)
else l=p;
//inserarea in teritoriul listei
while(l->adr!=0)
if (palindrom(l->adr->inf))
else l=l->adr;
return p;
void afisare(lista *p)
f<<endl;
void main()
l1->adr=0;
afisare(p);
//se insereaza succesorii numerelor de tip palindrom
p=inserare(p);
afisare(p);
f.close();
#include<fstream.h>
#include<conio.h>
int n,v[20];
ifstream f("date.in");
void interval(int &a,int &b)
void ordonare(int p,int u)
void main()
cout<<endl;
interval(pmin,pmax);
//se ordoneaza elementele vectorului dintre pozitiile pmin si pmax
ordonare(pmin+1,pmax-1);
for(i=1;i<=n;i++) cout<<v[i]<<" ";
#include<fstream.h>
#include<conio.h>
ifstream f("date.in");
int n,v[20];
void factori_primi(int x)
if(k==1)cout<<d<<" ";
d++;
cout<<endl;
int multime()
void main()
#include<fstream.h>
#include<stdlib.h>
#include<conio.h>
struct lista ;
ofstream f("date.out");
void scriere_lista(lista *p)
f<<endl;
lista *creare(int n)
a->adr=0;
return p;
int nr_perfect(int x)
void main()
while (n<1 || n>1000);
if (nr_perfect(n)) f<<n<<"este numar perfect"<<endl;
else f<<n<<"nu este numar perfect"<<endl;
//se construieste lista ce contine numere generate aleator
p=creare(n);
scriere_lista(p);
f.close();
#include<fstream.h>
#include<conio.h>
ifstream f("date.in");
int n,m,a[20] [20];
int rasturnat(int x)
return m;
int prim(int n)
void main()
j++;}
i++;}
if (ind) cout<<x<<" "<<ind<<endl;
else cout<<"Nu exista in matrice numere superprime\n";
//se determina elementul maxim din matrice
max=a[1] [1]; il=1; ic=1;
for(i=1; i<=n; i++)
for(j=1; j<=m; j++)
if(max<a[i] [j])
//se afiseaza vecinii (nenuli) ai maximului
if (a[il-1] [ic-1] !=0) cout<<a[il-1] [ic-1]<<" ";
if (a[il] [ic-1] !=0) cout<<a[il] [ic-1]<<" ";
if (a[il+1] [ic-1] !=0) cout<<a[il+1] [ic-1]<<" ";
if (a[il+1] [ic] !=0) cout<<a[il+1] [ic]<<" ";
if (a[il+1] [ic+1] !=0) cout<<a [il+1] [ic+1]<<" ";
if (a[il] [ic+1] !=0) cout<<a [il] [ic+1]<<" ";
if (a[il-1] [ic+1] !=0) cout<<a[il-1] [ic+1]<<" ";
if (a[il-1] [ic] !=0) cout<<a[il-1] [ic]<<" ";
#include<fstream.h>
#include<conio.h>
int v[30],n;
ifstream f ("date.in");
int mare(int x)
return m;
int prog_arit ()
void main ()
#include<fstream.h>
#include<conio.h>
ifstream f("date.in");
int n,a[20][20];
void transpusa()
int cmmdc(int x,int y)
void main()
#include<fstream.h>
#include<conio.h>
ifstream f("date.in");
int n,m,a[20][20],x;
void citire_matrice()
void eliminare()
int maxim()
int nr_cifre_distincte(int x)
while(x!=0)
for(int i=0,k=0;i<=9;i++)if(cifre[i]!=0)k++;
return k;
void main()
#include<fstream.h>
#include<string.h>
ifstream f("date.in");
char nume[20][20];int n;
void sortare()
}while(k>1);
for(i=1;i<=n;i++)cout<<nume[i]<<" ";
cout<<endl;
void main()
cout<<k;
12)#include<fstream.h>
#include<conio.h>
ifstream f("date.in");
int n,v[20],pare[20];void ordonare()
}while(k>1);
int sufix(int x,int y)
return 1;
int nr_cifre_pare(int x)
return nc;
void main()
for(i=1;i<=n;i++)pare[i]=nr_cifre_pare(v[i]);
ordonare();
for(i=1;i<=n;i++)cout<<v[i]<<" ";
#include<fstream.h>
#include<conio.h>
ifstream f("date.in");
long v[20];int n,pc[20];
int factorial(int x)
if(x==1)return d-1;
else return 0;
int prima_cifra(int x)
void ordonare()
}while(k>1);
void main()
cout<<endl;
for(i=1;i<n;i++) pc[i]=prima_cifra(v[i]);
ordonare();
for(i=1;i<=n;i++)cout<<v[i]<<" ";}
#include<fstream.h>
#include<conio.h>
ifstream f("date.in");
long v[20];int n;
int fibonaci(int x)
if(c==x)return 1;
else return 0;
void ordonare()
while(k>1);}
void main()
#include<fstream.h>
#include<math.h>
#include<conio.h>
struct lista
ifstream f("date.in");
lista *creare_lista(int &s,int &k)
s+=a->inf;k++;b=new lista;a->adr=b;f>>b->inf;}
a->adr=p;f.close();
return pr;}
void scriere(lista*p)
while(x!=p);
cout<<endl;
void main()
#include<fstream.h>
#include<conio.h>
ifstream f("date.in");
int n,m; float a[20][20];
void margini()
int max_linie(int i)
return c;
int min_coloana(int j)
return l;
void main()
if (t) cout<<"\nPunct sa ("<<il_min<<","<<ic_max<<")";
else cout<<"Nu exista punct sa";
#include<fstream.h>
#include<conio.h>
struct lista;
ifstream f("date.in");
int n,v[20];
void citire_fisier()
lista *creare_lista()
return p;
void scriere(lista*p)
cout<<endl;
void main()
#include<fstream.h>
#include<math.h>
#include<conio.h>
ofstream f("date.out");
unsigned long v[20]; int n;
void eliminare(unsigned long &x)
if (nc%2)
else
void citire()
void main()
#include<fstream.h>
#include<string.h>
#include<conio.h>
struct nume x[20];
ifstream f("date.in");
int n;
char v[20][30];
int numar_vocale(char c[])
void citire_nume()
f.close();
void ordonare()
while(k>1);
void main()
#include<fstream.h>
#include<conio.h>
struct interval x[20];
ifstream f("date.in");
int n;
void ordonare()
void main()
if(t) cout<<a<<" "<<b<<endl;
else cout<<"intervalele nu se intersecteaza\n";
//se ordoneaza intervalele dupa capatul din stanga
ordonare();
i=1;
k=0;
while(i<=n)
k++;}
cout<<k<<" ";
#include<fstream.h>
#include<conio.h>
struct cifre v[20];
ifstream f("date.in");
int n;
int nr_cifre_imp(unsigned long x)
return nc;
int minim_cifre()
int max(int min)
void main()
#include<fstream.h>
#include<conio.h>
struct nod_gr v[20];
ifstream f("graf.in");
int n,m,a[20] [20];
int grad(int x)
void ordonare()
}while (k>1);
void main( )
f.close();
for (i=1; i<=n; i++)
for (i=1; i<=n; i++)
ordonare();
for (i=1; i<=n; i++)
cout<<v[i].nod<<"(gr - "<<v[i].gr<<")";
#include<fstream.h>
#include<conio.h>
ifstream f("graf.in");
int n,a[20] [20],viz[20];
void parcurgere_latime()
p++;}
for (i=1; i <= u; i++) cout<<v[i]<<" ";
void main()
f.close();
//nr, de muchii=suma elem. de deasupra diagonalei principale
for (s=0,i=1; i<=n; i++)
for (j=i+1; j<=n; j++) s+= a[i] [j];
cout<<"Graful are "<<s<< "muchii iar acestea sunt:"<<endl;
for (i=1; i <= n; i++)
for (j=i+1; j <= n; j++)
if (a[i] [j]) cout<<"("<<i<<","<<j<<")"<<endl;
parcurgere_latime();
#include<fstream.h>
#include<conio.h>
ifstream f("graf.in");
int n,a[20] [20],viz[20];
void parcurgere_latime(int x,int y)
p++; }
for (t=0,i=1; i<=u&&t==0; i++) if (y==v[i]) t = 1;
if(t)
cout<<"nodurile "<<x<<" si "<<y<<" apartin aceleiasi componente conexe";
else
cout<<"nodurile "<<x<<" si "<<y<<" nu apartin aceleiasi componente conexe";
int grad(int x)
void main()
f.close();
for(i=1; i<=n; i++) cout<<grad(i)<<" ";
cout<<endl;
cout<<"Introduceti nodurile x si y:\n";
cin>>x>>y;
parcurgere_latime(x,y);
#include<fstream.h>
#include<conio.h>
ifstream f("graf.in");
struct arc v[20];
int n,m;
void main()
f.close();
for(i=1; i <= m-1; i++) for(j=i+1; j <=m; j++)
if(v[i].x==v[j].y&&v[i].y==v[j].x)
cout<<"("<<v[i].x<<","<<v[i].y<<")"<<endl;
cout<<"matricea arce-varfuri"<<endl;
for (i=1; i<=n; i++)
|