1) Sa se ordoneze elementele pare ale unui vector in ordine crescatoare, iar cele impare in ordine descrescatoare.
#include<iostream>2) Sa se verifice cate perechi de elemente ale unui vector au primul element mai mare decat al doilea, egal cu al doilea, mai mic decat al doilea.
using namespace std;
int main()
{int n,i,j,a[100],aux;
cout<<"n=";cin>>n;
for(i=0;i<n;i++)
{cout<<"a["<<i<<"]=";cin>>a[i];}
for(i=0;i<n;i++)
for(j=i+1;j<n;j++)
if(a[i]%2==0 && a[j]%2==0 && a[j]<a[i])
{aux=a[i];
a[i]=a[j];
a[j]=aux;}
for(i=0;i<n;i++)
for(j=i+1;j<n;j++)
if(a[i]%2==1 && a[j]%2==1 && a[j]>a[i])
{aux=a[i];
a[i]=a[j];
a[j]=aux;}
for(i=0;i<n;i++)
cout<<a[i]<<endl;
return 0;
}
#include<iostream>
using namespace std;
int main()
{int n,i,a[100],p,k,j;
cout<<"n=";cin>>n;
for(i=0;i<n;i++)
{cout<<"a["<<i<<"]=";cin>>a[i];}
p=k=j=0;
for(i=0;i<n-1;i++)
{if(a[i]>a[i+1])k++;
if(a[i]<a[i+1])p++;
if(a[i]==a[i+1])j++;}
cout<<k<<" perechi de nr cu prima cifra mai mare "<<endl;
for(i=0;i<n-1;i++)
if(a[i]>a[i+1])
cout<<a[i]<<";"<<a[i+1]<<endl;
cout<<p<<" perechi de nr cu prima cifra mai mica "<<endl;
for(i=0;i<n-1;i++)
if(a[i]<a[i+1])
cout<<a[i]<<";"<<a[i+1]<<endl;
cout<<j<<" perechi de nr cu cifrele egale "<<endl;
for(i=0;i<n-1;i++)
if(a[i]==a[i+1])
cout<<a[i]<<";"<<a[i+1]<<endl;
}