1
0
mirror of https://github.com/renbaoshuo/202401-programming-assignments.git synced 2024-12-16 15:44:39 +00:00
202401-programming-assignments/【实践课内】14.指针2/7-1 单词翻转.c

25 lines
373 B
C

#include <stdio.h>
#include <string.h>
const char *reverse(char *s) {
int len = strlen(s);
for (int i = 0; i < len / 2; i++) {
char temp = s[i];
s[i] = s[len - i - 1];
s[len - i - 1] = temp;
}
return s;
}
int main() {
char s[25];
while (scanf("%s", s) != EOF) {
printf("%s ", reverse(s));
}
return 0;
}