Pascal/Turbo Pascal - Figuras geométricas en una matriz

 
Vista:

Figuras geométricas en una matriz

Publicado por Abraham (1 intervención) el 09/07/2017 02:36:46
Hola amigo! soy nuevo en esto de la programación, cabe destacar que solo sé hacer matrices super simples,pero este ejercicio me mató el cerebro. Por favor ayudenme, tenga consideración por se un novato


El enunciado dice: Realizar un programa que dado un carácter cualquiera (que el usuario debe ingresar) y una figura geométrica de las opciones presentadas, usted debe realizar un programa que dibuje una figura dentro de
una matriz.
Dicho menú presentado debe contener tres figuras básicas y dos opcionales.
Figuras básicas: triangulo, circulo, cuadrado, rectángulo y las figuras opcionales ustedes la eligen sin tomarlas de las básicas.

Debe validar todas sus entradas al programa.


.

Por favor agradecería toda su ayuda.
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

Figuras geométricas en una matriz

Publicado por ramon (2158 intervenciones) el 08/08/2017 22:57:13
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
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
{Esto valdría}
 
program figuras;
  uses
     crt;
   const
      elmenu : array[1..4] of string[10] = (
      'triangulo', 'circulo', 'cuadrado', 'rectangulo');
      menuop : array[1..2] of string[10] = (
      'hexagono','rombo');
 
  type
     matriz = array[1..10,1..10] of char;
 
   var
     line, colum : integer;
     tecla, caract : char;
     figur : matriz;
     sal : boolean;
 
 
 
    procedure triangulo(car : char);
    begin
       figur[5,1] := car;
       colum := 5;
       for line := 1 to 4 do
       begin
       figur[line,colum] := car;
       colum := colum - 1;
       end;
       for line := 2 to 8 do
       figur[line,5] := car;
       line := 5;
       for colum := 1 to 5 do
       begin
          figur[line,colum] := car;
          line := line + 1;
       end;
       for line := 1 to 10 do
         for colum := 1 to 10 do
         if figur[line,colum] <> ' ' then
         begin
         gotoxy(line,colum);write(figur[line,colum]);
         end;
         gotoxy(1,13);write('  Pulse Una Tecla');
         readkey;
    end;
 
    procedure circulo(car : char);
    begin
       colum := 1;
       for line := 4 to 6 do
       figur[line,colum] := car;
       colum := 2;
       for line := 3 downto 1 do
       begin
         figur[line,colum] := car;
         colum := colum + 1;
       end;
       colum := 2;
       for line := 7 to 9 do
       begin
         figur[line,colum] := car;
         colum := colum + 1;
       end;
       line := 1;
       for colum := 5 to 6 do
       figur[line,colum] := car;
       line := 9;
       for colum := 5 to 6 do
       figur[line,colum] := car;
       colum := 7;
       for line := 2 to 4 do
       begin
        figur[line,colum] := car;
        colum := colum + 1;
       end;
         colum := 9;
         line := 5;
         figur[line,colum] := car;
         colum := 9;
        for line := 6 to 9 do
        begin
          figur[line,colum] := car;
          colum := colum - 1;
        end;
        for line := 1 to 10 do
         for colum := 1 to 10 do
         if figur[line,colum] <> ' ' then
         begin
         gotoxy(line,colum);write(figur[line,colum]);
         end;
         gotoxy(1,13);write('  Pulse Una Tecla');
        readkey;
    end;
 
    procedure cuadro(car : char);
    begin
       colum := 1;
       for line := 1 to 9 do
       figur[line,colum] := car;
       colum := 9;
       for line := 1 to 9 do
       figur[line,colum] := car;
       line := 1;
       for colum := 2 to 8 do
       figur[line,colum] := car;
       line := 9;
       for colum := 2 to 8 do
       figur[line,colum] := car;
       for line := 1 to 10 do
         for colum := 1 to 10 do
         if figur[line,colum] <> ' ' then
         begin
         gotoxy(line,colum);write(figur[line,colum]);
         end;
         gotoxy(1,13);write('  Pulse Una Tecla');
        readkey;
    end;
 
    procedure rectangulo(car : char);
    begin
       colum := 1;
       for line := 1 to 9 do
       figur[line,colum] := car;
       colum := 5;
       for line := 1 to 9 do
       figur[line,colum] := car;
       line := 1;
       for colum := 2 to 4 do
       figur[line,colum] := car;
       line := 9;
       for colum := 2 to 4 do
       figur[line,colum] := car;
       for line := 1 to 10 do
         for colum := 1 to 10 do
         if figur[line,colum] <> ' ' then
         begin
         gotoxy(line,colum);write(figur[line,colum]);
         end;
         gotoxy(1,13);write('  Pulse Una Tecla');
        readkey;
    end;
 
    procedure hexagono(car : char);
    begin
       colum := 1;
       for line := 4 to 7 do
       figur[line,colum] := car;
       colum := 7;
       for line := 4 to 7 do
       figur[line,colum] := car;
       line := 3;
       for colum := 2 to 4 do
       begin
       figur[line,colum] := car;
       line := line - 1;
       end;
       line := 7;
       for colum := 1 to 4 do
       begin
         figur[line,colum] := car;
         line := line + 1;
       end;
       colum := 4;
       for line := 1 to 3 do
       begin
           figur[line,colum] := car;
           colum := colum + 1;
       end;
        colum := 7;
        for line := 7 to 9 do
        begin
          figur[line,colum] := car;
          colum := colum - 1;
        end;
        for line := 1 to 10 do
         for colum := 1 to 10 do
         if figur[line,colum] <> ' ' then
         begin
         gotoxy(line,colum);write(figur[line,colum]);
         end;
         gotoxy(1,13);write('  Pulse Una Tecla');
        readkey;
       end;
 
    procedure rombo(car : char);
    begin
       colum := 5;
       for line := 1 to 5 do
       begin
         figur[line,colum] := car;
         colum := colum - 1;
       end;
       colum := 5;
       for line := 1 to 5 do
       begin
         figur[line,colum] := car;
         colum := colum + 1;
       end;
         line := 5;
         for colum := 1 to 5 do
         begin
         figur[line,colum] := car;
         line := line + 1;
       end;
        line := 5;
         for colum := 9 downto 5 do
         begin
         figur[line,colum] := car;
         line := line + 1;
       end;
        for line := 1 to 10 do
         for colum := 1 to 10 do
         if figur[line,colum] <> ' ' then
         begin
         gotoxy(line,colum);write(figur[line,colum]);
         end;
         gotoxy(1,13);write('  Pulse Una Tecla');
        readkey;
    end;
 
    procedure ocionales;
    var
      pulsa : char;
      term : boolean;
    begin
        term := false;
      repeat
        clrscr;
        writeln('   +++++ Menu Ociones +++++');
        writeln;
        writeln('  [H] = Hexagono');
        writeln('  [R] = Rombo');
        writeln('  [S] = Salir');
        writeln;
        writeln('  ---- Elija Opcion ----');
        repeat
            pulsa := upcase(readkey);
        until pulsa in['H','R','S'];
        fillchar(figur,sizeof(figur),' ');
        clrscr;
     case pulsa of
  'H' : hexagono(caract);
  'R' : rombo(caract);
  'S' : term := true;
     end;
     until term = true;
     clrscr;
    end;
 
    procedure menu;
    begin
       sal := false;
       clrscr;
       write('   Entre caracer : ');
       repeat
          caract := readkey;
      until caract in['A'..'Z','a'..'z'];
      clrscr;
     repeat
       clrscr;
       writeln('   ******* Menu General ******* ');
       writeln('   ---------------------------- ');
       writeln;
       writeln('   [T] = Triangulo');
       writeln('   [C] = Circulo');
       writeln('   [D] = Cuadro');
       writeln('   [R] = Rectangulo');
       writeln('   [O] = Ocionales');
       writeln('   [S] = Salir' );
       writeln;
       writeln('  >>>> Elija Opcion <<<<');
       repeat
       tecla := upcase(readkey);
       until tecla in['T','C','D','R','O','S'];
       clrscr;
       fillchar(figur,sizeof(figur),' ');
     case tecla of
  'T' : triangulo(caract);
  'C' : circulo(caract);
  'D' : cuadro(caract);
  'R' : rectangulo(caract);
  'O' : ocionales;
  'S' : sal := true;
    end;
     until sal = true;
    end;
 
 
 
    begin
       menu;
    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