随笔分类 - c语言笔记
摘要:智能灯改造计划 写在前面 由于最近购买了一个天猫精灵,于是就想着能不能自己DIY一个智能灯出来,看看身边的工具,唯一能激起我改造动力的就是身边的这个氛围灯了,因为平时使用它的频率最高,晚上使用也不会刺眼睛,所以它就成了我的不二之选;其实这个灯买回来的时候也挺好的,能红外线控制,调节灯光颜色亮度,以及
阅读全文
摘要:#include #include #define MAXSIZE 5 using namespace std; typedef struct { char *elem; //储存空间基地址 int length; //当前长度 }SqList; //初始化顺序表 int InitList(SqList *L) { L->elem=new char[MAXSIZE];...
阅读全文
摘要:#if 1 #include #include #include using namespace std; struct Node { int data; Node *next; }; //初始化 Node *init() { Node *head=new Node; head->next=NULL; return head; } //头插法创建节点 void insetLis...
阅读全文
摘要:#if 1 #include #include #include using namespace std; struct Node { int data; Node *next; }; //初始化 Node *init() { Node *head=new Node; head->next=NULL; return head; } //头插法创建节点 void insetLis...
阅读全文
摘要:#if 1 #include #include #include using namespace std; struct Node { int data; Node *next; }; //初始化 Node *init() { Node *head=new Node; head->next=NULL; return head; } //头插法创建节点 void insetLis...
阅读全文
摘要:总结:链表的遍历注意不要随意改变头指针的位置,进行合并时需要声明三个结构体指针用于进行合并,注意某一链表结束时需要进行链接,再释放生成的链表.
阅读全文
摘要:#include #include #define M 7 #define N 3 int main() { int a[M]={1,3,5,7,9,11,20}; int b[N]={2,6,8}; int c[M+N]={0}; int i=0; //a的下标 int j=0; //b的下标 int zu_he=0; //组合下标 ...
阅读全文
摘要:#include #include //先进行排序,在进行查找 void sort(int arr[10]) { int i,j,idx; for(i=0;iarr[j]) idx = j; } if(idx!=i) { int temp = arr[i]; ...
阅读全文
摘要:gcc编译C文件一共四步,预处理(Preprocess),编译(Compilation),汇编(Assembly)和链接(Linking) 1. 预处理(Preprocess) 预处理是预处理中会展开以#起始的行,包括#if、#ifdef、#if ndef、 #else 、 #elif 、 # en
阅读全文
摘要:/* 3、编写一个程序,实现如下功能: (1)将5个学生的信息(包括学号、姓名、成绩三项信息)写入到file1中。 (2)从file1中读出5个学生的信息,按成绩自高到低排序,排序后的结果写入到文件file2中。 */ #include #include #include #define N 5 typedef struct student { int num; char...
阅读全文
摘要:25 个人围成一个圈,从第1个人开始顺序报号,凡报号为3和3的倍数者退出圈子,找出最后留在圈子中的人原来的序号。 要求:用链表实现。报到3或3的倍数的结点删除; 提示:(1)需要将链表首尾相接形成环形; (2)删除时注意头、尾结点的特殊处理; (3)注意循环结束的条件;
阅读全文
摘要:1 #include 2 #include 3 #include 4 typedef struct student 5 { 6 int num; 7 float socre; 8 struct student *next; 9 }Student; 10 Student *creatlist(void) 11 { 12 Student *he...
阅读全文
摘要:1 #include 2 #include 3 #include 4 typedef struct student 5 { 6 int num; 7 float socre; 8 struct student *next; 9 }Student; 10 11 Student *creatlist(void) //创建空链表,头节点 12 { 13...
阅读全文