C语言字符串排序
作者:互联网
#include <stdio.h> #include<math.h> #include<string.h> int main() { char a[3][5] = { "123","234","345" }; for(int i=0;i<3;i++) for (int j = i; j < 3; j++) { char t[5]; if(strcmp(a[i], a[j])==-1)//如果后面的大 发生交换 { strcpy_s(t, a[i]); strcpy_s(a[i],a[j]); strcpy_s(a[j],t); } } for (int i = 0; i < 3; i++) { printf("%s\n",a[i]); } return 0; }
标签:main,排序,int,C语言,char,345,字符串,include 来源: https://www.cnblogs.com/lyonn/p/16179387.html