![](https://img-blog.csdnimg.cn/20201014180756738.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数据结构
Cachel wood
这个作者很懒,什么都没留下…
展开
-
数据结构上机习题2:两个一元多项式的和
#include <stdio.h>#include <stdlib.h> typedef struct LinkNode{ int coef;//系数 int index;//指数 struct LinkNode *next; }LinkNode,*LinkList; LinkList createLinkNode(){ LinkList L=(LinkList) malloc(sizeof(LinkNode)); L->next=NULL; p.原创 2021-06-25 21:18:52 · 514 阅读 · 0 评论 -
数据结构上机习题1. 约瑟夫(Josephu)问题
#include <stdio.h>#include <stdlib.h>#define LEN sizeof(struct node *)struct node{ int data; struct node *link;};void Josephu(int n, int m, int k){ int i; struct node *H, *d, *p; H = (struct node *)malloc(LEN); H->.原创 2021-06-24 17:52:46 · 100 阅读 · 0 评论 -
数据结构上机作业4. n阶魔方(n为奇数)
理论基础#include <stdio.h># define ROW 5void MAGIC(int M[ROW][ROW],int n){ int i, j, num; i = 0; j = n/2; for (num = 1;num<=n*n; num++) { //printf("(i,j) = (%d,%d)\n",i,j); if(M[i][j] == 0){ .原创 2021-06-24 17:52:29 · 153 阅读 · 0 评论 -
数据结构上机习题3. 计算矩阵鞍点
#include <stdio.h>void setupmatrix(int m, int n,int M[][n]){ int i,j; for(i=0;i<m;i++){ for(j=0;j<n;j++){ scanf("%d",&M[i][j]); } }}void printmatrix(int m,int n,int M[][n]){ int i,j; for(.原创 2021-06-24 17:52:09 · 386 阅读 · 0 评论 -
数据结构上级习题8:二叉排序树
#include <stdio.h>#include <stdlib.h>struct Treenode{ int Data; struct Treenode *Lchild, *Rchild;};void Setuptree(struct Treenode **T, int b, struct Treenode *p, int tag ){ struct Treenode *x; x=(struct Treenode *) malloc(sizeof.原创 2021-06-24 17:51:47 · 371 阅读 · 0 评论 -
数据结构上级习题6:八皇后问题
#include<stdio.h>#define N 8char board[N+2][N+2];int count = 0;struct Pos{ int yos; //行偏移量 int xos; //列偏移量};struct Pos pos[3] = { { -1, -1 }, { -1, 0 }, { -1, 1 } };void Init(void){ for (int row = 0; row < N + 2; row++).原创 2021-06-24 17:51:28 · 73 阅读 · 0 评论 -
数据结构上机习题5:稀疏矩阵的加法运算
#include <stdio.h>#include <stdlib.h>typedef struct threetuple{ int x;//表示非零元素的行标 int y;//表示非零元素的列标 int value;//表示非零元的值}Triple;//用来存放三元组中每一个非零元素的信息typedef struct infor{ int col;//列数 int row;//行数 int counts;//存放非零元.原创 2021-06-24 17:50:58 · 426 阅读 · 1 评论 -
数据结构上机作业7:中缀表达式变后缀表达式
#include <stdio.h>#include <stdlib.h>struct shu{ int front; int rear;}OPND;struct others{ char *base; char *top; int size;}OPTR;char bijiao(char x, char y) { if (x == '+') { if (y == '+' || y == '-' || y =.原创 2021-06-24 17:50:35 · 95 阅读 · 0 评论 -
数据结构上机习题汇总
文章目录1.约瑟夫问题2.一元多项式的加法运算3.计算矩阵鞍点4.n阶魔方(n为奇数)5.稀疏矩阵的加法运算6.“八皇后”问题7.中缀表达式和后缀表达式8.二叉排序树9.有向图与有向路径10.快速排序和希尔排序1.约瑟夫问题2.一元多项式的加法运算3.计算矩阵鞍点4.n阶魔方(n为奇数)5.稀疏矩阵的加法运算6.“八皇后”问题7.中缀表达式和后缀表达式8.二叉排序树9.有向图与有向路径10.快速排序和希尔排序...原创 2021-07-08 15:04:00 · 1317 阅读 · 0 评论 -
数据结构上机习题9:有向图与有向路径
#pragma once#include<stdio.h>#include<stdlib.h>#define StackSize 100typedef int DataType; //栈元素类型定义typedef struct{ DataType stack[StackSize]; int top;}SeqStack;//将栈初始化为空栈只需要把栈顶指针top置为void InitStack(SeqStack *S){ S->top=0;//把栈顶指针置.原创 2021-06-24 17:49:40 · 171 阅读 · 0 评论 -
数据结构上机习题10:快速排序和希尔排序
#include <stdio.h>#include <stdlib.h>#include <time.h>void ShellSort(int V[], int n){ int compcnt=0,movecnt=0; int d=n, x, i, j,k; while (d > 1){ d = d/2; for (i=d; i<n; i++){ x = V.原创 2021-06-24 17:49:15 · 175 阅读 · 0 评论 -
数据结构第14周作业(排序算法汇总)
1.#include <stdio.h>#include <stdlib.h>#include <time.h>void Select_Sort(int V[], int n){ //V为数据表名,n为记录数// int i,j,pos,temp; int compcnt=0,movecnt=0; for (i = 1; i<n; i++){ pos = i ; // pos指示关键字值最小的记录//..原创 2021-06-11 19:30:52 · 126 阅读 · 1 评论 -
数据结构第12周作业(图、AOV网与拓扑排序)
mark原创 2021-05-30 21:42:42 · 782 阅读 · 3 评论 -
数据结构第七周作业(二叉树、霍夫曼树、度、层次)
1.(1)(2)叶子节点:N,K,M,H,I,J,E,F,P,C分支节点:L,G,D,A,B(3)各节点的度:A:3,B:3,C:0,D:4,E:0,F:0,P:0,G:3,H:0,I:0,J:0,L:1,K:0,M:0,N:0A:3, B:3, C:0, D:4, E:0, F:0, P:0, G:3, \\H:0, I:0, J:0, L:1, K:0, M:0, N:0\\A:3,B:3,C:0,D:4,E:0,F:0,P:0,G:3,H:...原创 2021-04-23 12:06:31 · 120 阅读 · 0 评论 -
数据结构第五周作业(广义表的深度、长度、存储结构)
1.请写出下列广义表的深度和长度。(1)A=()(2)B=(a)(3)C=(a,b,C)(4)D=(a,(A),(a,(b,(c,C))),d)(5)E=(a,(b,c),(d,(e),(f,(g))))(1)A = ()\\(2)B = ( a )\\(3)C = ( a, b, C)\\(4)D = ( a, (A), (a, (b, (c, C))), d )\\(5)E = ( a, ( b, c ), ( d, ( e ), ( f, ( g ))))(1)A=()(2)B=(a)(3原创 2021-04-09 19:26:17 · 5004 阅读 · 2 评论 -
数据结构第四周作业(栈、队列、递归)
1.元素a, b, c, d顺序入栈,请写出出栈时的所有可能的顺序和按栈操作不可能出现的序列。应该有14种情况(C48−C58=14C_4^{8} - C_{5}^{8} = 14C48−C58=14)a第一个出栈:abcd; acbd; acdb; abdc; adcb;a第二个出栈:bacd; badc;a第三个出栈:cbad; bcad;a第四个出栈:bcda; cbda; cdba; bdca; dcba;不可能出现的序列:adbc; cabd; cadb; dacb; dabc原创 2021-04-02 18:11:38 · 346 阅读 · 0 评论 -
数据结构第三周作业(数组、稀疏矩阵、三元组、杨辉魔方)
1.编写一个算法,计算n阶方阵A的两个对角线元素的和。A采用数组表示。#include <stdio.h>#define N 4int main(){ int A[N][N]; int i,j,m; for(i=0;i<N;i++){ for(j=0;j<N;j++){ scanf("%d",&m); A[i][j]=m; } }/* for(i=0原创 2021-03-26 11:58:29 · 367 阅读 · 1 评论 -
数据结构第二周作业(线性表的增删改查、链表)
1.(1)顺序存储结构和链式存储结构的优缺点顺序存储时,相邻数据元素的存放地址也相邻(逻辑与物理统一);要求内存中可用存储单元的地址必须是连续的。优点:存储空间利用率高。缺点:插入或删除元素时不方便。链式存储时,相邻数据元素可随意存放,但所占存储空间分两部分,一部分存放结点值,另一部分存放表示结点间关系的指针.优点:插入或删除元素时很方便,使用灵活。缺点:存储密度小(<1),存储空间利用率低。(2)使用情况顺序表适宜于做查找这样的静态操作;链表宜于做插入、删除这样的动态操作原创 2021-03-19 21:00:02 · 258 阅读 · 0 评论 -
数据结构第一周作业(物理结构、逻辑结构)
1、数据的特征是什么?下面的对象中有哪些是数据?你能举出生活中一些不是数据的对象吗?(1)PDF版的数据结构教程(2)计算机内的GPU芯片(3)网站内的网页(4)MOOC中心的视频课程(5)报纸 (6)病毒疫情信息(7)C语言源程序 (8)手机App答:数据的特征是1、种类,数据类型的多样性;2、速度,指获得数据的速度;3、可变性,妨碍了处理和有效地管理数据的过程;4、真实性,数据的质量;5、复杂性,数据量巨大,来源多渠道。(1)(3)(4)原创 2021-03-12 18:01:15 · 385 阅读 · 0 评论