题解 | #HJ106 字符串逆序#
字符逆序
http://www.nowcoder.com/practice/cc57022cb4194697ac30bcb566aeb47b
C语言版本
#include <stdio.h>
#include <string.h>
int main() {
char content[10001];
int length;
scanf("%[^\n]", content, &length);
length = strlen(content);
char reverse[length+1];
for (int i = 0; i < length; i++) {
reverse[i] = content[length-i-1];
}
reverse[length] = '\0';
printf("%s\n", reverse);
return 0;
}
Python版本
print(input()[::-1])