标签:style blog http color os io ar for 2014
二级指针找出最大的字符 :
#include <stdio.h>char maxchar(char * str, char** max){char da = *str; //先让最大的执行第一个字符*max = str;while (*str){if (*str > da){da = *str;*max = str;}str++;}return da;}int main(){char str[] = "hello liuwxeia";char * max = NULL;char ch = maxchar(str, &max);printf("%p\t%c\n", max, ch);printf("%p\n", &str);return 0;}

#include <stdio.h>void show_str(char **s, int n){int i;for (i = 0; i < n; i++){printf("%s\n", s[i]);}}void sort_str(char **s, int n){int i, j, min;char * temp;for (i = 0; i < n; i++){min = i;for (j = i + 1; j<n; j++)if (strcmp(s[min], s[j]) > 0)min = j;temp = s[min];s[min] = s[i];s[i] = temp;}}int main(){char *s[] = { "hello", "world", "liuwei", "xuanyuan", "nima" };show_str(s, 5);sort_str(s, 5);printf("*****************\n");show_str(s, 5);return 0;}

标签:style blog http color os io ar for 2014
原文地址:http://www.cnblogs.com/l6241425/p/3952224.html