标签:div while oid blog lib int code std char
头文件:
1 #include<stdlib.h> 2 #include<stdio.h> 3 #include<string.h>
函数原型:
void inverse(char *str);
方法一:
void inverse(char *str){ char *p1, *p2; char temp; p1 = str; p2 = str + strlen(str) - 1; while(p1 < p2){ temp = *p1; *p1 = *p2; *p2 = temp; p1++; p2--; } }
方法二:
1 void inverse(char *str){ 2 int i, j, temp; 3 4 i = 0; 5 j = strlen(str) - 1; 6 7 while (i < j){ 8 temp = str[i]; 9 str[i] = str[j]; 10 str[j] = temp; 11 i++; 12 --j; 13 } 14 15 }
标签:div while oid blog lib int code std char
原文地址:http://www.cnblogs.com/zhouquan-1992-04-06/p/6201123.html