Pascal/Turbo Pascal - me podrian ayudar porfavor

 
Vista:
Imágen de perfil de geordin

me podrian ayudar porfavor

Publicado por geordin (4 intervenciones) el 13/06/2015 05:47:32
esta es mi matriz ya hecha compilada sin errores lo que yo realmente quiero es insertarla en menú de opciones que ya también esta hecho mas abajo esta el programa de menú que le puse menusito el único problema no se como insertarla o acomodarla que cuando presione la opción tres me realice la matriz eh intentado de varias forma pero me sale error realemte seria de gran ayuda si me ayudaran


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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
PROGRAM pedro;
USES CRT;
 
CONST
   limfilas = 20;
limcolumnas = 20;
 
 type
matriz = array [1..limfilas,1..limcolumnas] of integer;
 
VAR
 
mat1,mat2,prod:matriz;
filas1,columnas1,filas2,columnas2:integer;
producto:boolean;
tecla:char;
 
procedure escribirpresent;
begin
textcolor(blue);
write('ESTE PROGRAMA SOLO MULTIPLICA MATRICES DE ORDEN NxN');
 
end;
 
 
  procedure leermatriz(var mat: matriz; var filas,columnas:integer);
var
i,j:integer;
begin
TEXTCOLOR(yellow);
write ('Introduzaca el numero de filas y columnas de su matriz: ');
writeln(' ');
 
writeln ;
WRITELN('');
write('Numero de filas = ');
writeln ('');
readln (filas);
writeln ('');
write('Numero de columnas = ');
writeln ('');
readln(columnas);
textcolor(white);
writeln ('');
writeln;
writeln('Ingrese los datos de la matriz por filas');
writeln(' ');
WRITELN(' ');
writeLN('Los elementos de la matriz son = ');
writeln(' ');
WRITELN(' ');
for i:= 1 to filas do
for j:= 1 to columnas do
 
 
begin
textcolor(9);
writeln;
write('Elemento  [',i,',',j,']=');
 
read (mat [i,j]);
 
end;
end {leer matriz};
 
 
procedure imprimirmatriz(var mat: matriz; filas,columnas:integer);
const
anchuracampo =5;
var
i,j:integer;
begin
writeln;
 
textcolor(white);
 
for i:= 1 to filas do
begin
writeln ('');
writeln;
for j:=1 to columnas do
write (mat[i,j]:anchuracampo);
writeln;
writeln ('');
end{for}
end {imprimirmatriz};
 
 
 
procedure multiplicarmat (var mat1,mat2,prod:matriz;filas1,columnas1,filas2,columnas2:integer; var producto:boolean);
var
i,j,k,suma:integer;
begin
  writeln ('');
producto:=(columnas1 = filas2) and (columnas2 = filas1) and (columnas1= columnas2) and (filas2= filas1);
if producto then
begin
 
for i:= 1 to filas1 do
for j:= 1 to columnas2 do
begin
 
suma:= 0;
for k:=1 to columnas1 do
suma:=suma+mat1[i,k]*mat2[k,j];
prod[i,j]:=suma
end{forj}
end {if}
end {multiplicarmat};
begin
 
leermatriz (mat1,filas1,columnas1);
TEXTCOLOR(yellow);
writeln ('Su primer matriz es');
imprimirmatriz (mat1,filas1,columnas1);
writeln('');
leermatriz(mat2,filas2,columnas2);
TEXTCOLOR(white);
writeln ('Su segunda matriz es');
writeln;
 
imprimirmatriz (mat2,filas2,columnas2);
multiplicarmat (mat1,mat2,prod,filas1,columnas1,filas2,columnas2,producto);
if producto then
begin
 
textcolor(white);
writeln ('El producto de las matrices es =');
imprimirmatriz (prod,filas1,columnas2);
textcolor(RED);
writeln('press any key when you are ready to close this program.');
tecla:=readkey;
end{if}
else
begin
clrscr;
textcolor(red);
clrscr;
gotoxy(9,2);
writeln ('ERROR, el programa solo puede multiplicar matrices NxN,');
gotoxy(9,2);
writeln('el numero de columnas (',columnas1:1,'); de la primera matriz');
gotoxy(9,4);
writeln ('no es igual al numero de filas (',filas2:1,'); de la segunda matriz');
textcolor(green);
gotoxy(9,6);
writeln('press any key when you are ready to close this program.');
tecla:=readkey;
end;
clrscr;
end.

este es el programa del menu donde quiero inserta la matriz

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
PROGRAM MENUCITO;
USES CRT;
 
 
 
 
VAR
   OPC:INTEGER;
   TECLA:CHAR;
 
 
 
 
 
BEGIN
CLRSCR;
 
repeat
textcolor(9);
GOTOXY(22,5);
WRITE('MENU DE OPCIONES DEL SISTEMA ');
GOTOXY(22,8);
WRITE(' 1) TEORIA Y CONCEPTOS BASICOS SOBRE MATRICES ');
GOTOXY(22,10);
WRITE(' 2) RESTRICCIONES DEL SISTEMA ');
GOTOXY(22,12);
WRITE(' 3) MULTIPLICAR MATRICES NxN ');
GOTOXY(22,14);
WRITE(' 4) SALIR DEL PROGRAMA');
GOTOXY(22,16);
WRITE(' SELECCIONE SU OPCION: ');
READ(OPC);
IF ( OPC >=1 ) AND ( OPC <= 4 ) THEN
BEGIN
     CASE OPC OF
     1:BEGIN
       clrscr;
       textcolor(red);
       GOTOXY(22,5);
       WRITE('PRESIONE UNA TECLA PARA RETORNAR AL MENU');
       TECLA:=READKEY;
       clrscr;
       END;
 
     2:BEGIN
       CLRSCR;
       textcolor(red);
        GOTOXY(22,5);
       WRITE('PRESIONE UNA TECLA PARA RETORNAR AL MENU');
       TECLA:=READKEY;
       clrscr;
       END;
     3:BEGIN
       CLRSCR;
       TEXTCOLOR(RED);
       GOTOXY(22,5);
       WRITE('PRESIONE UNA TECLA PARA RETORNAR AL MENU');
       TECLA:=READKEY;
       clrscr;
       END;
     4:BEGIN
        clrscr;
        textcolor(GREEN);
        GOTOXY(22,5);
        write('GRACIAS POR UTILIZAR NUESTRO SISTEMA');
        TEXTCOLOR(RED);
        GOTOXY(22,7);
        WRITE('PRESIONE UNA TECLA PARA RETORNAR AL PROGRAMA');
        TECLA:=READKEY;
        clrscr;
       END;
 
 
END;
END
ELSE
BEGIN
   TEXTCOLOR(GREEN);
   GOTOXY(22,20);
   WRITE('OPCION NO ENCONTRADA POR FAVOR VERIFIQUE');
   TEXTCOLOR(RED);
   GOTOXY(22,22);
   WRITE('PRESIONE UNA TECLA PARA RETORNAR AL PROGRAMA');
   TECLA:=READKEY;
   clrscr;
 
END;
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

me podrian ayudar porfavor

Publicado por ramon (2158 intervenciones) el 13/06/2015 23:55:42
Mira para poder realizar lo que quieres tienes que poner PROGRAM MENUCITO; como un procedimiento al final y
llamarlo al iniciar o sea begin menucito;
o bien convertir pedro; en unidad y ponerla en el menú así USES CRT, pedro;
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
Imágen de perfil de geordin

me podrian ayudar porfavor

Publicado por geordin (4 intervenciones) el 14/06/2015 02:58:26
por favor podrías ser mas especifico es que no entiendo ya que copio la matriz al menú pero abajo arriba o dentro de la opción que quiero que este es que ya llevo varios días y no se ya me estoy frustrando ?????????
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

me podrian ayudar porfavor

Publicado por ramon (2158 intervenciones) el 14/06/2015 13:55:12
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
{Mira esto es lo tuyo }
 
PROGRAM pedro;
USES CRT;
 
CONST
   limfilas = 20;
limcolumnas = 20;
 
 type
matriz = array [1..limfilas,1..limcolumnas] of integer;
 
VAR
 
mat1,mat2,prod:matriz;
filas1,columnas1,filas2,columnas2:integer;
producto:boolean;
tecla:char;
 
procedure escribirpresent;
begin
textcolor(blue);
write('ESTE PROGRAMA SOLO MULTIPLICA MATRICES DE ORDEN NxN');
 
end;
 
 
  procedure leermatriz(var mat: matriz; var filas,columnas:integer);
var
i,j:integer;
begin
TEXTCOLOR(yellow);
write ('Introduzaca el numero de filas y columnas de su matriz: ');
writeln(' ');
 
writeln ;
WRITELN('');
write('Numero de filas = ');
writeln ('');
readln (filas);
writeln ('');
write('Numero de columnas = ');
writeln ('');
readln(columnas);
textcolor(white);
writeln ('');
writeln;
writeln('Ingrese los datos de la matriz por filas');
writeln(' ');
WRITELN(' ');
writeLN('Los elementos de la matriz son = ');
writeln(' ');
WRITELN(' ');
for i:= 1 to filas do
for j:= 1 to columnas do
 
 
begin
textcolor(9);
writeln;
write('Elemento  [',i,',',j,']=');
 
read (mat [i,j]);
 
end;
end {leer matriz};
 
 
procedure imprimirmatriz(var mat: matriz; filas,columnas:integer);
const
anchuracampo =5;
var
i,j:integer;
begin
writeln;
 
textcolor(white);
 
for i:= 1 to filas do
begin
writeln ('');
writeln;
for j:=1 to columnas do
write (mat[i,j]:anchuracampo);
writeln;
writeln ('');
end{for}
end {imprimirmatriz};
 
 
 
procedure multiplicarmat (var mat1,mat2,prod:matriz;filas1,columnas1,filas2,columnas2:integer; var producto:boolean);
var
i,j,k,suma:integer;
begin
  writeln ('');
producto:=(columnas1 = filas2) and (columnas2 = filas1) and (columnas1= columnas2) and (filas2= filas1);
if producto then
begin
 
for i:= 1 to filas1 do
for j:= 1 to columnas2 do
begin
 
suma:= 0;
for k:=1 to columnas1 do
suma:=suma+mat1[i,k]*mat2[k,j];
prod[i,j]:=suma
end{forj}
end {if}
end {multiplicarmat};
 
 
procedure resultado;
begin
leermatriz (mat1,filas1,columnas1);
TEXTCOLOR(yellow);
writeln ('Su primer matriz es');
imprimirmatriz (mat1,filas1,columnas1);
writeln('');
leermatriz(mat2,filas2,columnas2);
TEXTCOLOR(white);
writeln ('Su segunda matriz es');
writeln;
 
imprimirmatriz (mat2,filas2,columnas2);
multiplicarmat (mat1,mat2,prod,filas1,columnas1,filas2,columnas2,producto);
if producto then
begin
 
textcolor(white);
writeln ('El producto de las matrices es =');
imprimirmatriz (prod,filas1,columnas2);
textcolor(RED);
writeln('press any key when you are ready to close this program.');
tecla:=readkey;
end{if}
else
begin
clrscr;
textcolor(red);
clrscr;
gotoxy(9,2);
writeln ('ERROR, el programa solo puede multiplicar matrices NxN,');
gotoxy(9,2);
writeln('el numero de columnas (',columnas1:1,'); de la primera matriz');
gotoxy(9,4);
writeln ('no es igual al numero de filas (',filas2:1,'); de la segunda matriz');
textcolor(green);
gotoxy(9,6);
writeln('press any key when you are ready to close this program.');
tecla:=readkey;
end;
clrscr;
end;
 
 
 procedure menucito;
 VAR
   OPC:INTEGER;
 
BEGIN
CLRSCR;
 
repeat
textcolor(9);
GOTOXY(22,5);
WRITE('MENU DE OPCIONES DEL SISTEMA ');
GOTOXY(22,8);
WRITE(' 1) TEORIA Y CONCEPTOS BASICOS SOBRE MATRICES ');
GOTOXY(22,10);
WRITE(' 2) RESTRICCIONES DEL SISTEMA ');
GOTOXY(22,12);
WRITE(' 3) MULTIPLICAR MATRICES NxN ');
GOTOXY(22,14);
WRITE(' 4) SALIR DEL PROGRAMA');
GOTOXY(22,16);
WRITE(' SELECCIONE SU OPCION: ');
READ(OPC);
IF ( OPC >=1 ) AND ( OPC <= 4 ) THEN
BEGIN
     CASE OPC OF
     1:BEGIN
       clrscr;
       textcolor(red);
       GOTOXY(22,5);
       WRITE('PRESIONE UNA TECLA PARA RETORNAR AL MENU');
       TECLA:=READKEY;
       clrscr;
       END;
 
     2:BEGIN
       CLRSCR;
       textcolor(red);
        GOTOXY(22,5);
       WRITE('PRESIONE UNA TECLA PARA RETORNAR AL MENU');
       TECLA:=READKEY;
       clrscr;
       END;
     3:BEGIN
       CLRSCR;
       TEXTCOLOR(RED);
       GOTOXY(22,5);
       WRITE('PRESIONE UNA TECLA PARA RETORNAR AL MENU');
       TECLA:=READKEY;
       clrscr;
       END;
     4:BEGIN
        clrscr;
        textcolor(GREEN);
        GOTOXY(22,5);
        write('GRACIAS POR UTILIZAR NUESTRO SISTEMA');
        TEXTCOLOR(RED);
        GOTOXY(22,7);
        WRITE('PRESIONE UNA TECLA PARA RETORNAR AL PROGRAMA');
        TECLA:=READKEY;
        clrscr;
       END;
 
 
END;
END
ELSE
BEGIN
   TEXTCOLOR(GREEN);
   GOTOXY(22,20);
   WRITE('OPCION NO ENCONTRADA POR FAVOR VERIFIQUE');
   TEXTCOLOR(RED);
   GOTOXY(22,22);
   WRITE('PRESIONE UNA TECLA PARA RETORNAR AL PROGRAMA');
   TECLA:=READKEY;
   clrscr;
 
END;
 
 
begin
    menucito;
end.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar