-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproblema 3.c
More file actions
130 lines (119 loc) · 2.9 KB
/
Copy pathproblema 3.c
File metadata and controls
130 lines (119 loc) · 2.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
//3. Traspuesta
//Librerias
#include <conio.h>
#include <stdio.h>
#include <stdlib.h>
//Prototipos
void titulo ();
void dimension(int *m,int *n);
void lectura (int m, int n, int M[][n]);
void impresionOG (int m, int n, int M[][n]);
void trasponer (int m, int n, int M[][n], int W[][m]);
void impresionNW (int m, int n, int W[][m]);
void salida (char *op);
//Principal
int main(){
int m,n;
char op;
do{
titulo ();
dimension(&m,&n);
int M[m][n];
lectura(m,n,M);
impresionOG(m,n,M);
int W[m][n];
trasponer(m,n,M,W);
impresionNW(m,n,W);
fflush(stdin);
salida (&op);
}while(op == 's' || op == 'S');
printf ("\n");
getch();
return 0;
}
void titulo(){
printf("\tOBTENGA LA TRASPUESTA DE UNA MATRIZ\n");
}
void dimension (int *m,int *n){
int error;
do{
error=0;
printf("\n%c Ingrese el n%cmero de filas en su matriz: ",219,163);
scanf("%d",m);
printf("\n%c Ingrese el n%cmero de columnas en su matriz: ",219,163);
scanf("%d",n);
if (*m<2 || *n<2){
printf ("\n ERROR: Alguna dimensi%cn ingresada es menor a 2",162);
error=1;
getch();
system("cls");
}
}while(error!=0);
printf ("\n");
}
void lectura (int m, int n, int M[][n]){
int i, j;
system ("cls");
titulo ();
printf ("\n%c Ingrese los valores de su matriz en las siguientes posiciones:\n\n",219);
printf (">>>>Recuerde que acaba de ingresar una matriz de %d x %d<<<<\n\n",m,n);
for(i = 0; i < m; i++){
printf("\n///// FILA %d\n\n",i);
for(j = 0; j < n; j++){
printf("[%d][%d] >>> ",i, j);
scanf("%d",&M[i][j]);
}
}
}
void impresionOG (int m, int n, int M[][n]){
int i, j;
printf ("\n%c Esta es su matriz ingresada:\n\n",219);
for(i = 0; i < m; i++){
for(j = 0; j < n; j++){
printf("[%d]\t",M[i][j]);
}
printf("\n");
}
getch();
}
void trasponer (int m, int n, int M[][n], int W[][m]){
int i, j;
for(i = 0; i < m; i++){
for(j = 0; j < n; j++){
W[j][i] = M[i][j];
}
}
}
void impresionNW (int m, int n, int W[][m]){
int i, j;
printf ("\n%c Esta es su matriz traspuesta:\n\n",219);
for(i = 0; i < n; i++){
for(j = 0; j < m; j++){
printf("[%d]\t",W[i][j]);
}
printf("\n");
}
}
void salida (char *op){
int error;
do{
error=0;
printf("\n%cIngresar otra matriz? (s/n) %c ",168,175);
scanf("%s",op);
fflush(stdin);
if (*op == 's' || *op == 'S'){
system("cls");
}
else{
if (*op == 'n' || *op == 'N'){
system("cls");
printf("\n\n\tGRACIAS POR USAR NUESTROS SERVICIOS");
printf("\n\n\t Equipo 8\t-\tBUAP");
}
else{
printf("\n[!] ERROR: Ingresa una opci%cn valida [!]",162);
error = 1;
}
}
}while(error!=0);
}