Skip to content

Commit 9c1bbfa

Browse files
Code: added code for 100-rot13.c
1 parent 901f09b commit 9c1bbfa

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#include "main.h"
2+
#include <stdio.h>
3+
4+
/**
5+
* rot13 - encoder rot13
6+
*
7+
* @s: pointer to string params
8+
*
9+
* Return: *s
10+
*/
11+
12+
char *rot13(char *s)
13+
{
14+
int a = 0;
15+
16+
while (s[a])
17+
{
18+
while ((s[a] >= 'a' && s[a] <= 'z') || (s[a] >= 'A' && s[a] <= 'Z'))
19+
{
20+
if ((s[a] > 'm' && s[a] <= 'z') || (s[a] > 'M' && s[a] <= 'Z'))
21+
{
22+
s[a] -= 13;
23+
break;
24+
}
25+
26+
s[a] += 13;
27+
break;
28+
}
29+
30+
a++;
31+
}
32+
33+
return (s);
34+
}

0 commit comments

Comments
 (0)