Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
19
Task/Rot-13/MATLAB/rot-13-1.m
Normal file
19
Task/Rot-13/MATLAB/rot-13-1.m
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
function r=rot13(s)
|
||||
if ischar(s)
|
||||
r=s; % preallocation and copy of non-letters
|
||||
for i=1:size(s,1)
|
||||
for j=1:size(s,2)
|
||||
if isletter(s(i,j))
|
||||
if s(i,j)>=97 % lower case
|
||||
base = 97;
|
||||
else % upper case
|
||||
base = 65;
|
||||
end
|
||||
r(i,j)=char(mod(s(i,j)-base+13,26)+base);
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
error('Argument must be a CHAR')
|
||||
end
|
||||
end
|
||||
5
Task/Rot-13/MATLAB/rot-13-2.m
Normal file
5
Task/Rot-13/MATLAB/rot-13-2.m
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
>> rot13('Hello World!')
|
||||
|
||||
ans =
|
||||
|
||||
Uryyb Jbeyq!
|
||||
13
Task/Rot-13/MATLAB/rot-13-3.m
Normal file
13
Task/Rot-13/MATLAB/rot-13-3.m
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
function text = rot13(text)
|
||||
if ischar(text)
|
||||
|
||||
selectedLetters = ( (text >= 'A') & (text <= 'Z') ); %Select upper case letters
|
||||
text(selectedLetters) = char( mod( text(selectedLetters)-'A'+13,26 )+'A' );
|
||||
|
||||
selectedLetters = ( (text >= 'a') & (text <= 'z') ); %Select lower case letters
|
||||
text(selectedLetters) = char( mod( text(selectedLetters)-'a'+13,26 )+'a' );
|
||||
|
||||
else
|
||||
error('Argument must be a string.')
|
||||
end
|
||||
end
|
||||
11
Task/Rot-13/MATLAB/rot-13-4.m
Normal file
11
Task/Rot-13/MATLAB/rot-13-4.m
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
>> plainText = char((64:123))
|
||||
|
||||
plainText =
|
||||
|
||||
@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{
|
||||
|
||||
>> rot13(plainText)
|
||||
|
||||
ans =
|
||||
|
||||
@NOPQRSTUVWXYZABCDEFGHIJKLM[\]^_`nopqrstuvwxyzabcdefghijklm{
|
||||
Loading…
Add table
Add a link
Reference in a new issue