摘要:
C语言 实现链表 链表概念 链表是一种物理存储单元上非连续、非顺序的存储结构,数据元素的逻辑顺序是通过链表中的指针链接次序实现的。 链表由一系列结点(链表中每一个元素称为结点)组成,结点可以在运行时动态生成。 每个结点包括两个部分:一个是存储数据元素的数据域,另一个是存储下一个结点地址的指针域。 相 阅读全文
2022年3月21日 #
摘要:
栈 Stack 介绍 栈(stack)又名堆栈,它是一种运算受限的线性表。限定仅在表尾进行插入和删除操作的线性表。这一端被称为栈顶,相对地,把另一端称为栈底。 向一个栈插入新元素又称作进栈、入栈或压栈,它是把新元素放到栈顶元素的上面,使之成为新的栈顶元素; 从一个栈删除元素又称作出栈或退栈,它是把栈 阅读全文
摘要:
用C语言实现从1+2+3+n+100 #include <stdio.h> int plus(int); int main(void) { int n = 0; n = plus(n); printf("%d\n",n); return 0; } int plus(int n) { return n 阅读全文
摘要:
test1.c //error #include <stdio.h> int main(void) { int i = 5; const int *p = &i; printf("%d\n",*p); *p = 10; printf("%d\n",*p); return 0; } test2.c / 阅读全文
摘要:
定义基本类型的别名 #include <stdio.h> typedef int Integer; int main(void) { Integer a = 5,b = 10; printf("%d\n",a+b); return 0; } /* typedef不是必须声明在函数外,也可以声明在一个 阅读全文
摘要:
#include <stdio.h> #include <malloc.h> int *LoadInt(int); int main(void) { int x = 0; int *p; p = LoadInt(20); while(x < 20) { printf("%d\n",p[x]); x+ 阅读全文
摘要:
指向无参函数的指针 #include <stdio.h> int Integer(void); char Char(void); int main(void) { int (*a)() = Integer; char (*b)() = Char;; printf("%d\n%c\n",a(),b() 阅读全文
摘要:
用指针作形参,实现输出参数,交换两变量的值。 #include <stdio.h> void jiaohuan(int *,int *); int main(void) { int a=100,b=200; jiaohuan(&a,&b); printf("%d\n%d\n",a,b); retur 阅读全文
摘要:
C语言多级指针 (指向指针的指针) #include <stdio.h> int main(void) { int i = 100,j = 200; int *p; int **q; int ***l; p = &i; q = &p; l = &q; printf("%d\n%d\n%d\n%d\n 阅读全文
摘要:
C语言 enum 枚举常量 #include <stdio.h> enum WeekDay { MonDay,TuesDay,WednesDay = 5,ThursDay,FriDay,SaturDay,SunDay }; int main(void) { enum WeekDay Day = Fr 阅读全文