Вы находитесь на странице: 1из 1

1.

-
//intercambia fila con columna
#include "stdafx.h"
#include "iostream"
#include "conio.h"
using namespace std;

int _tmain(int argc, _TCHAR* argv[])


{ int i,j,n;
int mat[10][10];
int aux[10];
int k,l;
cout<<"Ingrese n: ";
cin>>n;
cout<<"Ingrese valores"<<endl;
for(i=1;i<=n;i++)
for(j=1;j<=n;j++)
{ cout<<"Ingrese mat["<<i <<"]["<<j<<"]= ";
cin>>mat[i][j];};
for(i=1;i<=n;i++)
{for(j=1;j<=n;j++)
cout<<"\t"<<mat[i][j]<<" ";
cout<<endl;}

cout<<"Ingrese fila k: "; cin>>k;


cout<<"Ingrese columna l: "; cin>>l;
//cargando fila K
for(j=1;j<=n;j++)
aux[j]=mat[k][j];
//colocando la columna l en la fila k
for(i=1;i<=n;i++)
mat[k][i] = mat[i][l];
for(i=1;i<=n;i++)
mat[i][l] = aux[i];
for(i=1;i<=n;i++)
{for(j=1;j<=n;j++)
cout<<"\t"<<mat[i][j]<<" ";
cout<<endl;}
system("pause");
return 0;
}

Вам также может понравиться