#define _CRT_SECURE_NO_WARNINGS
#include"stdio.h"
#include"stdlib.h"
#include"string.h"
//二维数组字符串排序..不调用函数//指针类型不一样。=====》内存模型不一样吧。。。。
void main1()
{
//定义一个指针类型的数组;
char myStrout[][30] = { "cccccc", "aaaaaa", "bbbbbbb", "1111111" };
char buf[3][30];a
int i = 0;
int j = 0;
char *p = (char *)malloc(100);; //err 类型是 char *p=null;没有分配空间不好存放字符串;
//排序前;
for (i = 0; i < 4; i++)
{
printf("%s\n", myStrout[i]);
}
for (i = 0; i < 4; i++)
{
for (j = i + 1; j < 4; j++)
{
if (strcmp(myStrout[i], myStrout[j])<0)
{
strcpy(p, myStrout[j]);
strcpy(myStrout[j], myStrout[i]);
strcpy(myStrout[i], p);
}
}
}
free(p);
printf("\n\n\n");
//排序后;
for (i = 0; i < 4; i++)
{
printf("%s\n", myStrout[i]);
}
system("pause");
}
//调用函数
int myprintf(const char myStrIPUT[][30])
{
char *p = (char *)malloc(100);
//err 类型是 char *p=null;没有分配空间不好存放字符串;
int j = 0;
int i = 0;
for (i = 0; i < 4; i++)
{
for (j = i + 1; j < 4; j++)
{
if (strcmp(myStrIPUT[i], myStrIPUT[j]) < 0)
{
strcpy(p, myStrIPUT[j]);
strcpy(myStrIPUT[j], myStrIPUT[i]);
strcpy(myStrIPUT[i], p);
}
}
}
free(p);
}
int paixu(char myinput[][30],int n)
{
int i = 0;
for (i = 0; i < n; i++)
{
printf("%s\n", myinput[i]);
}
}
void main()
{
//定义一个指针类型的数组;
char myStrout[10][30] = { "cccccc", "aaaaaa", "bbbbbbb", "1111111" };
paixu(myStrout, 4);
printf("\n\n\n");
myprintf(myStrout);
paixu(myStrout, 4);
system("pause");
}