题解 | #字符逆序#
字符逆序
https://www.nowcoder.com/practice/cc57022cb4194697ac30bcb566aeb47b
#include <stdio.h> #include <string.h> void fun(char *str, int len){ char tmp; for(int i = 0; i < len - 1 -i; i++){ tmp = str[len - 1 - i]; str[len - 1 - i] = str[i]; str[i] = tmp; } } int main(){ char str[10001] = {'\0'}; fgets(str, sizeof(str), stdin); str[strlen(str) - 1] = '\0'; int len = strlen(str); fun(str, len); printf("%s", str); return 0; }