摘要: 解题思路: 1、插入排序的特点:从左往右扫描,前段数据非递减,当出现第一个递减的位置,再和原数据比较,此后若数据位置不变,则为插入排序。 2、堆排序的特点:从第2个位置起,一直找到第一个比首位数据大的数据止。 #include <stdio.h> #include <string.h> int Ju 阅读全文
posted @ 2020-03-13 23:17 跃鱼 阅读(1788) 评论(0) 推荐(0) 编辑
摘要: 解题思路:采用并查集思想 判断连通分量个数,当攻占一座城市后,图的连通分量变多,则表明影响图的连通性 #include <stdio.h> #include <string.h> int f[500]; int getf(int x) { if(f[x]==x) return x; return f 阅读全文
posted @ 2020-03-13 20:42 跃鱼 阅读(284) 评论(1) 推荐(0) 编辑
摘要: 函数接口定义: void K_Reverse( List L, int K ); 其中List结构定义如下: typedef struct Node *PtrToNode; struct Node { ElementType Data; /* 存储结点数据 */ PtrToNode Next; /* 阅读全文
posted @ 2020-03-13 17:59 跃鱼 阅读(1074) 评论(0) 推荐(0) 编辑
摘要: 解题思路:采用邻接矩阵存储 1、先确定输入数据的个数是否等于顶点数+1 2、访问完每个顶点后标记 3、判断首尾顶点是否一致 #include <stdio.h> #include <string.h> #define MaxVex 210 int G[MaxVex][MaxVex]; int vis 阅读全文
posted @ 2020-03-13 15:58 跃鱼 阅读(624) 评论(0) 推荐(0) 编辑