1) Sa se inverseze coloanele unei matrici cu n linii si m coloane.Varianta R0il.
#include<iostream>1) Varianta proprie
using namespace std;
int main()
{int n,m,i,j,a[100][100],aux,p=0,k;
cout<<"n=";cin>>n;
cout<<"m=";cin>>m;
for(i=0;i<n;i++)
for(j=0;j<m;j++)
{cout<<"a["<<i<<"]["<<j<<"]=";cin>>a[i][j];}
for(i=0;i<n;i++)
{k=m-1;
for(j=0;j<m/2;j++)
{aux=a[i][j];
a[i][j]=a[i][k];
a[i][k]=aux;
k--;}
}
for(i=0;i<n;i++)
{cout<<endl;
for(j=0;j<m;j++)
cout<<a[i][j]<<" ";}
}
#include<iostream>2) Sa se cauta intr-o matrice un element. Sa se afiseze linia si coloana pe care apare.
using namespace std;
int main()
{int n,m,i,j,a[100][100],aux,p=0,k;
cout<<"n=";cin>>n;
cout<<"m=";cin>>m;
for(i=0;i<n;i++)
for(j=0;j<m;j++)
{cout<<"a["<<i<<"]["<<j<<"]=";cin>>a[i][j];}
i=0;j=m-1;p=0;
while(i<m/2 && j>=m/2 && p<n)
{aux=a[p][i];
a[p][i]=a[p][j];
a[p][j]=aux;
i++;j--;
if(i==j || i>j)
{p++;i=0;j=m-1;}
}
for(i=0;i<n;i++)
{cout<<endl;
for(j=0;j<m;j++)
cout<<a[i][j]<<" ";}
}
#include<iostream> //3)
using namespace std;
int main()
{int n,m,i,j,a[100][100],aux,p,k,ok=0;
cout<<"n=";cin>>n;
cout<<"m=";cin>>m;
cout<<"p=";cin>>p;
for(i=0;i<n;i++)
for(j=0;j<m;j++)
{cout<<"a["<<i<<"]["<<j<<"]=";cin>>a[i][j];}
for(i=0;i<n;i++)
for(j=0;j<m;j++)
if(a[i][j]==p)
{cout<<"linia "<<i<<" coloana "<<j<<endl;ok=1;}
if(ok==0)
cout<<"Nu a fost gasit";
}