Sie sind auf Seite 1von 1

#include <stdio.

h>
#include <stdlib.h>

/* run this program using the console pauser or add your own getch, system("pause")
or input loop */
int matriz[3][5] = {11, 12, 13, 14, 15, 21, 22, 23, 24 , 25, 31, 32, 33, 34, 35};
int aux[5][3];
int transposta[5][3];

int main(int argc, char *argv[]) {

PreencheMatriz();
printf("\n----------------\n");
Transpor();

return 0;
}

void PreencheMatriz(){
int i, j;

/*for (i = 0; i < 3; i++) {


for (j = 0; j < 5; j++) {
scanf("%d", &matriz[i][j]);
}
}*/

for (i = 0; i < 3; i++) {


for (j = 0; j < 5; j++) {
printf("%d ", matriz[i][j]);
}
printf("\n");
}
printf("\n----------------\n");
}

void Transpor()
{
int i, j, k;
for (i = 0; i < 3; i++) {
for (j = 0; j < 5; j++) {
transposta[i][j] = matriz[j][i];
}
printf("\n");
}

for (i = 0; i < 5; i++) {


for (j = 0; j < 3; j++) {
printf("%d ", transposta[i][j]);
}
printf("\n");
}
}

Das könnte Ihnen auch gefallen