1
0
mirror of https://github.com/renbaoshuo/202401-programming-assignments.git synced 2024-11-23 15:48:42 +00:00

【实践课内】9.数组3

This commit is contained in:
Baoshuo Ren 2024-11-15 16:03:08 +08:00
parent 1d65b207f1
commit e20c16a589
Failed to extract signature
8 changed files with 80 additions and 0 deletions

View File

@ -0,0 +1,18 @@
#include <stdio.h>
#include <string.h>
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;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 138 KiB

View File

@ -0,0 +1,23 @@
#include <stdio.h>
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;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 160 KiB

View File

@ -0,0 +1,21 @@
#include <stdio.h>
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;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 152 KiB

View File

@ -0,0 +1,18 @@
#include <stdio.h>
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;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 164 KiB