Skip to content

Commit b576f2e

Browse files
committed
Solution code for baekjoon/11655
1 parent e058631 commit b576f2e

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

strings/baekjoon/11655/solution.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#include <stdio.h>
2+
#include <string.h>
3+
4+
int main(void) {
5+
char s[128] = "";
6+
gets(s);
7+
int s_length = strlen(s);
8+
9+
char uppercase[26] = "NOPQRSTUVWXYZABCDEFGHIJKLM";
10+
char lowercase[26] = "nopqrstuvwxyzabcdefghijklm";
11+
12+
// Include terminating null character
13+
char ret[128] = "";
14+
15+
for (int index = 0 ; index < s_length ; index++) {
16+
// 65: A, 90: Z
17+
// 97: a, 122: z
18+
int temp = (int)s[index];
19+
if (65 <= temp && temp <= 90) {
20+
ret[index] = uppercase[temp - 65];
21+
} else if (97 <= temp && temp <= 122) {
22+
ret[index] = lowercase[temp - 97];
23+
} else {
24+
ret[index] = s[index];
25+
}
26+
27+
printf("%c", ret[index]);
28+
}
29+
30+
return 0;
31+
}

0 commit comments

Comments
 (0)