初始化元素为结构体的数组

严教材无法实现的地方

用指针实现数组快速复制

用指针交换结构体变量

进而实现冒泡排序

严教材无法实现的地方

#include <stdlib.h>
#include <malloc.h>
#define MAXSIZE 20

typedef struct
{
	int time;
	int value;
 } corrd;
 //为了排序不同个数组定义以下数据类型
 typedef struct
 {
 	corrd *a;  //a[0]闲置 
 	int length; 
  } SqList;
int InitList(SqList *L)
{
      L->a=malloc(sizeof(corrd)*(MAXSIZE+1));
      L->length=MAXSIZE+1;
     return 1;
}
 int main()
 {
 	corrd c[4]={{0,0},{12,87},{7,43},{10,22}};
 	SqList L;
 	InitList(&L);
 
 	printf("%d\n",L.length);
 	L.a=c;
 	printf("%d %d",L.a[2].time,L.a[3].value);
 	return 0;
 }
小作业小作业 文章被收录于专栏

小作业,姑且叫做操作步骤超过5步的作业吧

全部评论

相关推荐

06-28 22:48
已编辑
广东金融学院 Java
小浪_Coding:学院本+这俩项目不是buff叠满了嘛
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务