diff --git a/【实践课内】9.数组3/7-1 字符串逆序.c b/【实践课内】9.数组3/7-1 字符串逆序.c new file mode 100644 index 0000000..a6e92f1 --- /dev/null +++ b/【实践课内】9.数组3/7-1 字符串逆序.c @@ -0,0 +1,18 @@ +#include +#include + +char s[100]; + +int main() { + gets(s); + + int len = strlen(s); + + for (int i = len - 1; i >= 0; i--) { + printf("%c", s[i]); + } + + printf("\n"); + + return 0; +} diff --git a/【实践课内】9.数组3/7-1 字符串逆序.png b/【实践课内】9.数组3/7-1 字符串逆序.png new file mode 100644 index 0000000..f566043 Binary files /dev/null and b/【实践课内】9.数组3/7-1 字符串逆序.png differ diff --git a/【实践课内】9.数组3/7-2 字符串替换.c b/【实践课内】9.数组3/7-2 字符串替换.c new file mode 100644 index 0000000..b9a77e3 --- /dev/null +++ b/【实践课内】9.数组3/7-2 字符串替换.c @@ -0,0 +1,23 @@ +#include + +const char REPLACE_MAP[] = "ZYXWVUTSRQPONMLKJIHGFEDCBA"; + +char s[100]; + +int main() { + gets(s); + + int len = strlen(s); + + for (int i = 0; i < len; i++) { + if (s[i] >= 'A' && s[i] <= 'Z') { + printf("%c", REPLACE_MAP[s[i] - 'A']); + } else { + printf("%c", s[i]); + } + } + + printf("\n"); + + return 0; +} diff --git a/【实践课内】9.数组3/7-2 字符串替换.png b/【实践课内】9.数组3/7-2 字符串替换.png new file mode 100644 index 0000000..9de386c Binary files /dev/null and b/【实践课内】9.数组3/7-2 字符串替换.png differ diff --git a/【实践课内】9.数组3/7-3 统计字符出现次数.c b/【实践课内】9.数组3/7-3 统计字符出现次数.c new file mode 100644 index 0000000..0cc248f --- /dev/null +++ b/【实践课内】9.数组3/7-3 统计字符出现次数.c @@ -0,0 +1,21 @@ +#include + +char c, s[100]; + +int main() { + gets(s); + scanf("%c", &c); + + int len = strlen(s); + int cnt = 0; + + for (int i = 0; i < len; i++) { + if (s[i] == c) { + cnt++; + } + } + + printf("%d\n", cnt); + + return 0; +} diff --git a/【实践课内】9.数组3/7-3 统计字符出现次数.png b/【实践课内】9.数组3/7-3 统计字符出现次数.png new file mode 100644 index 0000000..20a31dc Binary files /dev/null and b/【实践课内】9.数组3/7-3 统计字符出现次数.png differ diff --git a/【实践课内】9.数组3/7-4 IP地址转换.c b/【实践课内】9.数组3/7-4 IP地址转换.c new file mode 100644 index 0000000..970031a --- /dev/null +++ b/【实践课内】9.数组3/7-4 IP地址转换.c @@ -0,0 +1,18 @@ +#include + +char s[100]; +int ip[4]; + +int main() { + scanf("%s", s); + + for (int i = 0; i < 4; i++) { + for (int j = 0; j < 8; j++) { + ip[i] = ip[i] * 2 + s[i * 8 + j] - '0'; + } + } + + printf("%d.%d.%d.%d\n", ip[0], ip[1], ip[2], ip[3]); + + return 0; +} diff --git a/【实践课内】9.数组3/7-4 IP地址转换.png b/【实践课内】9.数组3/7-4 IP地址转换.png new file mode 100644 index 0000000..0e05791 Binary files /dev/null and b/【实践课内】9.数组3/7-4 IP地址转换.png differ