Pascal/Turbo Pascal - Ayuda encriptar un mensaje en pascal!

 
Vista:
sin imagen de perfil

Ayuda encriptar un mensaje en pascal!

Publicado por Sabrina (9 intervenciones) el 03/07/2016 02:30:54
Hice este programa para voltear los caracteres.
lo que quiero saber es como puedo hacer para que se volteen desde el segundo espacio al quinto solamente y no la frase entera?
Un ejemplo seria: 'Hola, hoy nos juntamos en la casa de juan' - Esta es la frase original.
'Hola, hoy al ne somatnuj son casa de juan' - Esta es la frase encriptada.

Cualquier ayuda es bienvenida.

Aca les dejo lo que tengo hecho.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
Program Ejercicio (Output,input);
Uses Crt;
Var original:array[1..80] of string;
    invertida:array[1..80] of string;
    cadena:string;
    i:integer;
 
BEGIN
     Writeln('Ingrese el texto');writeln('');
     Readln(cadena);
     For i:=1 to length(cadena) do
     Begin
          original[i]:=cadena[i];
     End;
     Writeln('');
     writeln('');
     For i:=length(cadena) downto 1 do
     Begin
          Invertida[i]:=cadena[i];
          write(invertida[i]);
     End;
Readkey;
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

Ayuda encriptar un mensaje en pascal!

Publicado por ramon (2158 intervenciones) el 03/07/2016 16:27:55
quieres que te responda a todo lo que as puesto eso requiere un tiempo no seas impaciente te responderé poco a poco
espera.
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

Ayuda encriptar un mensaje en pascal!

Publicado por ramon (2158 intervenciones) el 03/07/2016 22:50:38
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
{Mira para ir asciendo boca mira esto}
 
 program encriptacion;
  uses
     crt;
  type
    cadenamax = string[80];
 
   const
      min = 2;
      max = 5;
   var
     cadena, encrip : cadenamax;
     cont : integer;
     cambio : array[1..80] of char;
     ini, tot : integer;
 
 
   procedure entrada_mensaje(var mensa : cadenamax);
   begin
      clrscr;
      writeln;
      writeln('   <<< Entre Mensaje Max 80 Caracteres >>>');
      writeln;
      write('   Mensaje : ');
      readln(mensa);
   end;
 
 
   procedure toma_blancos(nn : cadenamax);
   var
     bb, bla : integer;
     begin
         bb := 0;
         ini := 0;
         tot := 0;
         for bla := 1 to length(nn) do
         begin
            if nn[bla] = #32 then
            bb := bb + 1;
            if (bb = 2) and (ini = 0) then
            ini := bla + 1;
            if bb = 5 then
            begin
               tot := bla  - ini;
               break;
            end;
         end;
         if (bb < 5) and (ini > 0) then
         tot := bla  - ini;
     end;
 
     procedure procesa_cadena(dp : cadenamax);
     var
       temp : cadenamax;
       p,  t : integer;
       begin
          toma_blancos(dp);
          temp := copy(dp,ini,tot);
          p := 1;
          for t := length(temp) downto 1 do
          begin
             cambio[p] := temp[t];
             p := p + 1;
          end;
          for t := 1 to p - 1 do
          begin
          encrip[t] := cambio[t];
          encrip[0] := chr(t);
          end;
          delete(cadena,ini,tot);
          insert(encrip,cadena,ini);
          writeln;
          writeln('   ',cadena);
      end;
 
 
 
     begin
 
        entrada_mensaje(cadena);
        procesa_cadena(cadena);
 
       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

Ayuda encriptar un mensaje en pascal!

Publicado por ramon (2158 intervenciones) el 07/07/2016 11:31:07
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
{Mas para mirar}
 
 program robot;
 uses
    crt;
  const
 
      longordenmax = 25;
 
  type
    cuadros = array[0..20,0..20] of char;
    string25 = string[25];
 
 
   var
     tablero : cuadros;
     t, x, y : integer;
     mando : string25;
     posinix, posfinx, posiniy, posfiny : integer;
     origrnmodo : integer;
     tec : char;
 
   procedure iniciatablero;
   begin
      fillchar(tablero,sizeof(tablero),chr(1));
   end;
 
   procedure presentatablero(x1, y1 : integer);
   var
      t1, t2 : integer;
   begin
      clrscr;
      writeln('   ****** El Tablero ******');
      writeln;
      for t1 := 0 to 20 do
        for t2 := 0 to 20 do
        begin
        gotoxy(x1 + t2, y1 + t1);write(tablero[t1,t2]);
        end;
   end;
 
   function cordenadasx(xcmax : integer) : boolean;
   begin
       if (xcmax < 20) or (xcmax > - 0) then
       cordenadasx := true
    else
       cordenadasx := false;
   end;
 
 
    function cordenadasy(ycmax : integer) : boolean;
    begin
       if (ycmax < 20) or (ycmax > - 0) then
       cordenadasy := true
    else
       cordenadasy := false;
   end;
 
   procedure ponposicionrobot(xr, yr : integer);
   begin
      tablero[yr,xr] := chr(2);
   end;
 
   procedure entradacoryman(var x1, y1 : integer; var baston : string25);
   begin
      clrscr;
      writeln('   **** Entrada Cordenadas X E Y De Inicio Y Mando ****');
      writeln;
      write('  Posicion columnas : ');
      readln(x1);
      write('  Posicion filas    : ');
      readln(y1);
      write('  Mando : ');
      readln(baston);
      posinix := x1;
      posiniy := y1;
      posfinx := 0;
      posfiny := 0;
   end;
 
 
   begin
      origrnmodo := lastmode;
      textmode(c80 + font8x8);
      clrscr;
      iniciatablero;
      entradacoryman(x,y,mando);
      if (cordenadasx(x) = true) and (cordenadasy(y) = true) then
      begin
      ponposicionrobot(x,y);
      for t := 1 to length(mando) do
      begin
   case mando[t] of
  'n','N' : y := y + 1;
  's','S' : y := y - 1;
  'e','E' : x := x + 1;
  'o','O' : x := x - 1;
     end;
       if (cordenadasx(x) = true) and (cordenadasy(y) = true) then
       begin
          tablero[y,x] := chr(2);
       end;
      end;
      posfinx := x;
      posfiny := y;
      presentatablero(10,3);
      writeln;
      writeln('   Posicion Inicial : ',posinix,'x',
      posiniy,'   Posicion Final : ',posfinx,'x',posfiny);
 repeat
      writeln('   Desea Entrar Mas Mandotos [S/N]');
    repeat
        tec := upcase(readkey);
    until tec in['S','N'];
    if tec = 'S' then
    begin
       iniciatablero;
       x := posfinx;
       y := posfiny;
       write('  Mando : ');
       readln(mando);
       ponposicionrobot(x,y);
       posinix := x;
       posiniy := y;
      for t := 1 to length(mando) do
      begin
   case mando[t] of
  'n','N' : y := y + 1;
  's','S' : y := y - 1;
  'e','E' : x := x + 1;
  'o','O' : x := x - 1;
     end;
       if (cordenadasx(x) = true) and (cordenadasy(y) = true) then
       begin
          tablero[y,x] := chr(2);
       end;
      end;
      posfinx := x;
      posfiny := y;
      presentatablero(10,3);
      writeln;
      writeln('   Posicion Inicial : ',posinix,'x',
      posiniy,'   Posicion Final : ',posfinx,'x',posfiny);
    end;
    until tec = 'N';
      end
   else
      writeln('  Fuera de cordenadas pulse una tecla');
      textmode(origrnmodo);
   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