1)2 copii
#include<iostream>
using namespace std;
int main()
{int a[100],b[100],n,i,aux,p=0,k=0,ordonat=0;
cout<<"n=";cin>>n;
for(i=0;i<n;i++)
{cout<<"a["<<i<<"]=";cin>>a[i];}
for(i=0;i<n;i++)
{cout<<"b["<<i<<"]=";cin>>b[i];}
do{ordonat=1;
for(i=0;i<n-1;i++)
if(a[i]>a[i+1]){aux=a[i];
a[i]=a[i+1];
a[i+1]=aux;
k++;
ordonat=0;}}
while(ordonat==0);
do{ordonat=1;
for(i=0;i<n-1;i++)
if(b[i]>b[i+1]){aux=b[i];
b[i]=b[i+1];
b[i+1]=aux;
p++;
ordonat=0;}}
while(ordonat==0);
cout<<k<<";"<<p<<endl;
if(k>p)cout<<"al doilea castiga";
if(p>k)cout<<"primul castiga";ator p
if(k==p)cout<<"=";
}
2)
Sa se ordoneze un sir: crescator pana la jumatate, descrescator de la jumatate
#include<iostream> //
using namespace std;
int main()
{int a[100],n,i,aux,ordonat=0;
cout<<"n=";cin>>n;
for(i=0;i<n;i++)
{cout<<"a["<<i<<"]=";cin>>a[i];}
do{ordonat=1;
for(i=0;i<n/2-1;i++)
if(a[i]>a[i+1]){aux=a[i];
a[i]=a[i+1];
a[i+1]=aux;
ordonat=0;}}
while(ordonat==0);
do{ordonat=1;
for(i=n/2;i<n-1;i++)
if(a[i]<a[i+1]){aux=a[i];
a[i]=a[i+1];
a[i+1]=aux;
ordonat=0;}}
while(ordonat==0);
for(i=0;i<n;i++)cout<<a[i]<<endl;
}
3)
Sa se ordoneze un sir crescator dupa suma cifrelor elementelor
#include<iostream>
using namespace std;
int main()
{int a[100],n,i,p,aux,ordonat=0,b[100]={0};
cout<<"n=";cin>>n;
for(i=0;i<n;i++)
{cout<<"a["<<i<<"]=";cin>>a[i];}
for(i=0;i<n;i++)
{p=a[i];
while(p){b[i]=b[i]+p%10;
p=p/10;}}
do{ordonat=1;
for(i=0;i<n-1;i++)
if(b[i]>b[i+1]){aux=a[i];
a[i]=a[i+1];
a[i+1]=aux;
aux=b[i];
b[i]=b[i+1];
b[i+1]=aux;
ordonat=0;}}
while(ordonat==0);
for(i=0;i<n;i++)cout<<a[i]<<endl;
}