#include<stdio.h> #include<stdlib.h> //构建线性表结构 typedef struct LNode *List; struct LNode{ int data[1000]; int last; }; //生成线性表 List createList(int arr[],int arrLen){ List L= (List)malloc(sizeof(struct LNode)); L->last=0; for(int i=0;i<=arrLen;…
#include<stdio.h> #include<stdlib.h> //构建线性表结构 typedef struct LNode *List; struct LNode{ int data[1000]; int last; }; //生成线性表 List createList(int arr[],int arrLen){ List L= (List)malloc(sizeof(struct LNode)); L->last=0; for(int i=0;i<=arrLen;…
#include<stdio.h> #include<stdlib.h> typedef struct QueueNode *PtrToNode; struct QueueNode { /* 队列中的结点 */ int Data; PtrToNode Next; }; typedef PtrToNode Position; struct QNode { Position Front, Rear; /* 队列的头、尾指针 */ int MaxSize; /* 队列最大容量 */ }; type…
算结构题练习题吧 Talk is cheap,show you the code. #include<stdio.h> #include<math.h> #include<string.h> typedef struct complex{ double real; double virt; }COM; //复数求和的实现函数 COM summation(COM num1,COM num2){ COM result; result.real=num1.real+num2.real;…
花时间研究了一下两种不同的排序算法,下面给出介绍。 1 . 冒泡排序算法 比较相邻的元素。如果第一个比第二个大,就交换他们两个。 对每一对相邻元素做同样的工作,从开始第一对到结尾的最后一对。在这一点,最后的元素应该会是最大的数。 针对所有的元素重复以上的步骤,除了最后一个。 持续每次对越来越少的元素重复上面的步骤,直到没有任何一对数字需要比较。 #include<stdio.h> int a[10]; void sort(int a[],int n){ for(int i=1;i<n;i++){ …
COPYRIGHT © 2016 - 2021 Titan笔记. ALL RIGHTS RESERVED.