今天讲了共用体,里面只算最大的字节数。最后赋谁,共用体就是谁。临时的数据用共用体。
枚举,enum color
{
red,blue,yellow
};
int main()
{
printf(“%d”,red);
}
队列,先到先处理。
二分法,有序的数组,找中间值确定区间,输入的数如果大于中间值,中间值变成新的下限,再从新的下限和上限中取中间值,输入的数小于中间值,中间值变成新的上限,从新的上限和下限取中间值,直到找到为止。
链表
#include<stdio.h>
#include<alloc.h>
#include<stdlib.h>
struct stu
{
int m;
char a;
struct stu *next;
};
int main()
{
printf("%d",sizeof(stu));
int i;
struct stu *head;
if(head==NULL)
{
head=(struct stu*)malloc(sizeof(struct stu));
}
scanf("%d",&head->m);
struct stu * next; 定义结构体类型的指针
for(i=0;i<5;i++)
{
next=(struct stu*)malloc(sizeof(struct stu));malloc是在内存中申请一个空间,头文件为stdlib.h
scanf("%d",&next->m);
}
//free(指针);//清除一排
}