Pascal/Turbo Pascal - espiral

 
Vista:

espiral

Publicado por Alejandro (29 intervenciones) el 18/05/2012 03:49:49
Hola quisiera hacer un programa en pascal, que cuando le de ctrl+f9, me escriba los numeros que ingrese en espiral, osea q me pida ingresar los numeros y luego de ingresarlos todos me imprima en un cuadro de 4x4 los numero que ingrese pero en espiral osea q haga un espiral.
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

espiral

Publicado por ramon (2158 intervenciones) el 18/05/2012 23:31:06
Creo me comenta esto en modo texto lo cual indica la generación de 4x4 16 números
metidos en ese cuadro un poquito escaso no puesto que quedaría algo asín.

1 2 3 4
14 5
13 18 15 6
12 17 16 7
8 9 10 11

no puede ser asta terminar los números es ved de 4x4.
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
sin imagen de perfil
Val: 36
Ha aumentado su posición en 4 puestos en Pascal/Turbo Pascal (en relación al último mes)
Gráfica de Pascal/Turbo Pascal

espiral

Publicado por Armando Fuenmayor (43 intervenciones) el 19/05/2012 21:16:46
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
program espi;
uses crt;
var
 i, j ,fi , co: integer;
 espiral, matriz : array[1..4,1..4] of integer;
    C : char;
    verdad : boolean;
procedure fico(fila,columna: integer; var ii,jj:integer);
begin
  if (fila = 1) and (columna = 1) then
  begin
    ii := 3;
    jj := 2 ;
  end;
  if (fila = 1) and (columna = 2) then
  begin
    ii := 3;
    jj := 3 ;
  end;
  if (fila = 1) and (columna = 3) then
  begin
    ii := 2;
    jj := 3 ;
  end;
  if (fila = 1) and (columna = 4) then
  begin
    ii := 2;
    jj := 2 ;
  end;
  (****************)
  if (fila = 2) and (columna = 1) then
  begin
    ii := 2;
    jj := 1 ;
  end;
  if (fila = 2) and (columna = 2) then
  begin
    ii := 3;
    jj := 1 ;
  end;
  if (fila = 2) and (columna = 3) then
  begin
    ii := 4;
    jj := 1 ;
  end;
  if (fila = 2) and (columna = 4) then
  begin
    ii := 4;
    jj := 2 ;
  end;
  (****************)
  if (fila = 3) and (columna = 1) then
  begin
    ii := 4;
    jj := 3 ;
  end;
  if (fila = 3) and (columna = 2) then
  begin
    ii := 4;
    jj := 4;
  end;
  if (fila = 3) and (columna = 3) then
  begin
    ii := 3;
    jj := 4 ;
  end;
  if (fila = 3) and (columna = 4) then
  begin
    ii := 2;
    jj := 4 ;
  end;
  (****************)
  if (fila = 4) and (columna = 1) then
  begin
    ii := 1;
    jj := 4 ;
  end;
  if (fila = 4) and (columna = 2) then
  begin
    ii := 1;
    jj := 3;
  end;
  if (fila = 4) and (columna = 3) then
  begin
    ii := 1;
    jj := 2 ;
  end;
  if (fila = 4) and (columna = 4) then
  begin
    ii := 1;
    jj := 1 ;
  end;
 
 
end;
 
 procedure mostrarespi;
 begin
    writeln('La matriz en Espiral:');
    writeln;
 for  i := 1 to 4 do
 begin
   for  j := 1 to 4 do
    begin
      write(espiral[i,j]:10);
     end;
     writeln;
     writeln;
  end;
      verdad := true;
end;
 
 
begin
clrscr;
    writeln;
    writeln(' La Matriz como se introdujo');
    writeln;
 
   for  i := 1 to 4 do
   begin
     for  j := 1 to 4 do
     begin
       write(' datos matriz fila: ', i ,' columna: ', j,'= ');
       readln(matriz[i,j]);
     end;
     writeln;
     writeln;
  end;
 
 
   for  i := 1 to 4 do
   begin
     for  j := 1 to 4 do
     begin
       fico(i,j,fi,co);
       espiral[fi,co]:= matriz[i,j];
       write(matriz[i,j]:10);
     end;
     writeln;
     writeln;
  end;
 
 verdad := false;
 repeat
   repeat
   Writeln('Presione Crtl+f9 para ver espiral');
   C := Readkey;
    Writeln(' tu presionaste ', C, ', el valor  ASCII es ', Ord(C), '.');
  until (C = chr(102));
 
 
       mostrarespi;
 
 
  until (verdad = true);
 
  readln;
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

espiral

Publicado por Luis (29 intervenciones) el 21/05/2012 00:33:48
hola asi llevo el ejercicio no se sivoy bien quisiera q se viera mas centrado y menos pegado para q se distinga bien el espiral

program espiral;
uses crt;
var
n1,n2,n3,n4,i,numeros:integer;

begin
clrscr;
writeln('Ingrese primer Numero');
readln(n1);
writeln('Ingrese segundo Numero');
readln(n2);
writeln('Ingrese tercer Numero');
readln(n3);
writeln('Ingrese cuarto Numero');
readln(n4);

begin
clrscr;
for i:= 4 to 4 do

begin
gotoxy (28,12);write(n1);
gotoxy (30,12);write(n2);
gotoxy (32,12);write(n3);
gotoxy (34,12);write(n4);

gotoxy (34,13);write(1);
gotoxy (34,15);write(1);
gotoxy (34,17);write(1);
gotoxy (34,19);write(1);

gotoxy (34,21);write(1);
gotoxy (31,21);write(1);
gotoxy (28,21);write(1);
gotoxy (25,21);write(1);

gotoxy (24,19);write(1);
gotoxy (24,17);write(1);

gotoxy (26,16);write(1);
gotoxy (29,16);write(1);
end;
end;
readkey
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

espiral

Publicado por ramon (2158 intervenciones) el 22/05/2012 17:27:27
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
{A ver si esto ayuda algo}
 
 program espiral;
 uses
   crt;
   const
      espira : array[1..16] of array[1..2] of integer = (
      (1,1),(4,1),(7,1),(10,1),(10,3),(10,5),(10,7),
      (7,7),(4,7),(1,7),(1,5),(1,3),(4,3),(7,3),
      (7,5),(4,5));
  var
    numeros : array[1..16] of integer;
    tec : char;
    valor : word;
    ii : integer;
 
   procedure entranumeros;
   var
      nu : integer;
   begin
       nu := 1;
       while nu <> 17 do
       begin
       clrscr;
       writeln('  Entre 16 numeros ');
       writeln;
       write(' N§ : ',nu,' : ');
       readln(numeros[nu]);
       nu := nu + 1;
      end;
   end;
 
   procedure presentaenespiral;
   var
      t, y, i : integer;
   begin
       t := 1;
       y := 1;
       for i := 1 to 16 do
       begin
       t := espira[i][1];
       y := espira[i][2];
       gotoxy(5 + t,5 + y);write(numeros[i]);
  end;
 end;
 
  begin
      clrscr;
      entranumeros;
      clrscr;
      writeln('Pulse CTRL + F9');
      repeat
      tec := readkey;
      if tec = #0 then
      valor := word(ord(readkey)) shl 8
    else
      valor := ord(readkey);
      writeln(valor);
      until valor = 26112;
      clrscr;
      writeln;
      for ii := 1 to 16 do
      write('  ',numeros[ii]);
      writeln;
      presentaenespiral;
      gotoxy(4,18);write('Pulse [Enter]');
      readln;
  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