
C语言
计算机老师小飞
这个作者很懒,什么都没留下…
展开
-
三维整形数组代码实现
本文以三维整形数组的方式来演示1.三维数组主要是为了更好理解多维数组元素的位置2.直接以int整形而不是ElemType方式是为了简化代码#include <stdio.h>#include <stdlib.h>//定义三维整形数组 typedef struct tdarray{ int m1; int m2; int m3; int *array;}TDArray;//创建三维数组void Create(TDArray *tdarray, int m1,原创 2021-10-14 20:44:40 · 316 阅读 · 0 评论 -
简单一维数组的代码实现
数组中的元素按一定的顺序存放在一个连续的存储空间中#include <stdio.h>#include <stdlib.h>//数组的简单操作代码//为了便于理解,简化操作,作了如下删减// 1.只是操作一维数组//2.只有核心代码,没有进行健壮性处理,即没有返回错误信息这些代码 //定义一维数组typedef struct array{ int m; int *array;}Array;//创建数组void Create(Array *a,int m)原创 2021-10-14 19:55:25 · 401 阅读 · 0 评论 -
简单递归函数的实现
递归函数是指调用自己的函数;分为直接递归和间接递归编写代码计算n的阶乘:n!以递归方式计算以循环语句计算并比较两者的区别#include <stdio.h>//以递归函数实现 //long Fact(long n)//{// if(n==1) return 1;// return n*Fact(n-1);//}//以循环语句实现long Fact(long n){ long temp=1,i; for(i=1;i<=n;i++) { temp *=原创 2021-10-14 19:51:21 · 321 阅读 · 0 评论 -
链式队列的操作
队列是一种特殊的线性表队列限定在表的一端插入、在表的另一端删除,其中队尾rear是新元素依次入队的位置,而队头front是队列中元素出队的位置。队列是一种先进先出(FIFO)的结构体,队列可用链式表来操作,代码如下所示#include <stdio.h>#include <stdlib.h>//定义队列结构体typedef int ElemType;typedef struct node{ ElemType elem; struct node *next;} N原创 2021-09-24 10:35:38 · 108 阅读 · 0 评论 -
链式栈的操作
堆栈的链式表示操作堆栈是一种限定在同一端进行插入和删除操作的线性结构允许执行插入和删除的这一 端称为栈顶(top),另一端为栈底堆栈有两种存储结构,顺序栈和链式栈以下为链式栈的操作代码#include <stdio.h> #include <stdlib.h> typedef int ElemType; //定义堆栈单链表 typedef struct node { ElemType elem; struct原创 2021-09-24 09:04:07 · 121 阅读 · 0 评论 -
顺序栈的操作
堆栈的顺序表示操作堆栈是一种限定在同一端进行插入和删除操作的线性结构允许执行插入和删除的这一 端称为栈顶(top),另一端为栈底堆栈有两种存储结构,顺序栈和链式栈以下为顺序栈的操作代码#include <stdio.h> #include <stdlib.h> //堆栈的定义 typedef int ElemType; typedef struct stack { int top; int maxSize; Elem原创 2021-09-24 09:00:53 · 79 阅读 · 0 评论 -
队列的顺序操作
队列是一种特殊的线性表队列限定在表的一端插入、在表的另一端删除,其中队尾rear是新元素依次入队的位置,而队头front是队列中元素出队的位置。队列是一种先进先出(FIFO)的结构体,队列可用线性顺序表来操作,代码如下所示:#include <stdio.h>#include <stdlib.h>//定义队列结构体 typedef int ElemType;typedef struct queue{ int front; int rear; int mSize原创 2021-09-24 08:55:31 · 651 阅读 · 0 评论 -
带表头结点的单链表
为了简化算法,可以在单链表的头结点之前增加一个表头结点表头结点的数据域中并不存放线性表中的数据元素#include <stdio.h>#include <stdlib.h>#define ERROR 0#define OK 1#define Overflow 2#define Underflow 3#define NotPresent 4#define Duplicate 5typedef int Status;//带表头结点的单链表的定义typedef in原创 2021-09-07 18:02:59 · 820 阅读 · 2 评论 -
冒泡排序算法
冒泡排序算法《信息系统分析与设计》练习代码课本P13【例1-1】结构化程序设计典型示例-冒泡法排序#include <stdio.h>#include <time.h>#include <conio.h>#include <windows.h>#include <stdlib.h>int Random(void);void BubbleSort(int a[],int n);int main(){ int i,j,temp原创 2021-09-06 15:07:20 · 92 阅读 · 0 评论 -
C语言程序设计 飞行小鸟游戏
通过C语言程序设计开发的一款飞行小鸟游戏,拥有3种游戏模式:玩家操作模式,自动游戏模式,人工智能模式代码如下:#include <stdio.h> #include <stdlib.h> #include <conio.h> #include <time.h> #include <windows.h> #define DIS 22 #define BLAN 9 #define M 16 #define N 16 typed原创 2021-01-17 20:20:16 · 1218 阅读 · 1 评论