Borrar filtros
Borrar filtros

What is wrong with my code ?

1 visualización (últimos 30 días)
muhammad usman
muhammad usman el 7 de Abr. de 2020
Comentada: Walter Roberson el 7 de Abr. de 2020
function coded = caesar(a,b);
x = length(a);
y = double(a);
for i = 1:x
y(i) = y(i) + b;
if y(i) > 126;
j = y(i)- 126;
y(i) = 31+j;
elseif y(i) < 32;
j = y(i) - 32;
y(i) = 127+j;
end
coded(i) =char(y(i));
end
end
  1 comentario
Walter Roberson
Walter Roberson el 7 de Abr. de 2020
What error do you observe?
It does feel a bit odd that newline (character position 10) is mapped to 'i' (lower-case I) when b is 0, but without specifications, we do not know that it is wrong.
Note that your function can emit characters beyond ~ if your input is ß (223) or beyond

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre MATLAB en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2016a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by