逆转字符串
#include <stdio.h> #include <string.h> char *reverse(char *str) { int i, j; for (i = 0, j = strlen(str) - 1; i < j; ++i, --j) { char tmp = str[i]; str[i] = str[j]; str[j] = tmp; } return str; } int main() { char str[100]; scanf("%s", str); reverse(str); printf("%s", str); return 0; }
原文地址:http://chhquan.blog.51cto.com/1346841/1567515