以拼音形式给名字排序
怎样以拼音形式给名字排序呢??
#include <stdio.h> #include <string.h> #define MAX_LEN 80 char str[][MAX_LEN] = {"zhang","ziang","zaang","zbang","zcang","zdang","zeang","zfang","zgang","zhang","\0"} ; int main ( void ) { int i, j; char temp[MAX_LEN] ; i = 0 ; printf ( "********************\n排序前:\n" ) ; while ( strcmp ( str[i], "\0" ) ) { puts ( str[i++] ) ; } /* **冒泡排序 */ for ( i = 0; strcmp ( str[i], "\0" ); i++ ) { for ( j = i + 1; strcmp ( str[j], "\0" ); j++ ) { if ( strcmp ( str[i], str[j] ) > 0 ) { strcpy ( temp, str[i] ) ; strcpy ( str[i], str[j] ) ; strcpy ( str[j], temp ) ; } } } i = 0 ; printf ( "********************\n排序后:\n" ) ; while ( strcmp ( str[i], "\0" ) != 0 ) { puts ( str[i++] ) ; } return 0 ; }