Pascal/Turbo Pascal - Ayuda urgente (Pascal)

 
Vista:
sin imagen de perfil

Ayuda urgente (Pascal)

Publicado por Tarari (1 intervención) el 28/04/2014 20:37:32
Buenas, me han surgido bastantes complicaciones al hacer estos 2 ejercicios en Pascal y me pregutaba si me los podriais facilitar resueltos:

1) Se trata de hacer un programa que calcule la suma de 2 matrices A y B. Se pediran las dimensiones y en caso de que se pueda hacer la suma, se introduciran los elementos de ambas matrices y se hara la suma.

2) Tenemos un array de 2 dimensiones de M x N. El contenido de cada elemento es una cadena de caracteres formada por un nombre y un numero (real o entero). Se pide crear 2 matrices que, viniendo de la original separe una cadena con la parte de los numeros y otra con la de los nombres, respetando su orden.
Por ultimo el programa nos dara nos dara el nombre correspondiente al menor numero.

Muchas gracias de antemano.
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

Ayuda urgente (Pascal)

Publicado por ramon (2158 intervenciones) el 01/05/2014 00:34:32
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
{Mira esto a ver si ayuda}
 
program matrizestexto;
 uses
    crt;
    const
       max = 20;
       m = 2;
       n = 2;
  type
     string100 = string[100];
     textoarray = array[1..m,1..n] of string100;
     matrisab = array[1..3,1..max] of integer;
     string20 = string[20];
   var
     matriz : matrisab;
     cont, x, y : integer;
     unid, dece : integer;
     txsuma : string20;
     lona, lonb : integer;
     cadena, numero : array[1..m,1..n] of string100;
     tex : textoarray;
 
 
   procedure entracadenas;
   var
     elnume : array[1..m,1..n] of real;
     peq, nnr : real;
     j, b, f, error : integer;
   begin
      clrscr;
      for x := 1 to m do
        for y := 1 to n do
        begin
           write('  Entre Nombre y Numero Matriz [ ',x,'/',y,' ] : ');
           readln(tex[x,y]);
        end;
      b := 1;
      for x := 1 to m do
      begin
        for y := 1 to n do
        begin
           for j := 1 to length(tex[x,y]) do
           if tex[x,y][j] <> ' ' then
           begin
             cadena[x,y][b] := tex[x,y][j];
             cadena[x,y][0] := chr(b);
             b := b + 1;
           end
        else
           begin
             j := j + 1;
             break;
           end;
        end;
        b := 1;
         for f := j to length(tex[x,y]) do
         begin
            numero[x,y][b] := tex[x,y][f];
            numero[x,y][0] := chr(b);
            b := b + 1;
         end;
         b := 1;
       end;
        for b := 1 to m do
        begin
          for f := 1 to n do
          begin
             val(numero[b,f],nnr,error);
             if error <> 0 then
             begin
                delete(numero[b,f],error,1);
                val(numero[b,f],nnr,error);
             end;
              elnume[b,f] := nnr;
          end;
         end;
         b := 0;
         f := 0;
         peq := 1231440.66;
         for x := 1 to m do
           for y := 1 to n do
           if elnume[x,y] < peq then
           begin
              peq := elnume[x,y];
              b := x;
              f := y;
           end;
         writeln;
         writeln('  El Numero Mas Pequeyo Pertenece A = ',cadena[b,f]);
         writeln;
         writeln('  Pulse Una Tecla');
         readkey;
   end;
 
 
 
   procedure asignanumero(h : integer;var num : matrisab;te : string20);
   var
      s, c, b : integer;
   begin
      s := (max - length(te)) + 1;
      for c := 1 to length(te) do
      begin
        if te[c] in['0'..'9'] then
        begin
          num[h,s] := ord(te[c]) - 48;
          s := s + 1;
        end;
      end;
        if h = 1 then
        lona := length(te);
        if h = 2 then
        lonb := length(te);
   end;
 
   procedure pidedatos;
   begin
      clrscr;
      write('   Entre Primer Sumando Max 20 Digitos  : ');
      readln(txsuma);
      asignanumero(1,matriz,txsuma);
      write('   Entre Segundo Sumando Max 20 Digitos : ');
      readln(txsuma);
      asignanumero(2,matriz,txsuma);
   end;
 
   procedure sumaarrais;
   var
      sum : integer;
   begin
       dece := 0;
       for y := 1 to lona do
       begin
          sum := (matriz[1,(max + 1) - y] + matriz[2,(max + 1) - y]) + dece;
          dece := 0;
          unid := sum mod 10;
          dece := (sum div 10) mod 10;
          matriz[3,(max + 1) - y] := unid;
       end;
         if dece > 0 then
         matriz[3,(max + 1) - (y + 1)] := dece;
     end;
 
   procedure presentasuma;
   begin
      pidedatos;
      clrscr;
      for cont := max downto (max - (lona - 1)) do
      begin
      gotoxy(5 + cont,2);write(matriz[1,cont]);
      end;
      for cont := max downto (max - (lonb - 1)) do
      begin
      gotoxy(5 + cont,3);write(matriz[2,cont]);
      end;
      for y := 1 to lona do
      begin
      gotoxy(((max - lona) + 5) + y,4);write('Ä');
      end;
      sumaarrais;
      for y := 1 to lona do
      begin
         gotoxy((5 + (max + 1)) - y,5);write(matriz[3,(max + 1) - y]);
      end;
      readkey;
   end;
 
 
 
   begin
       presentasuma;
       entracadenas;
   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