![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数据结构
Water.Melon
这个作者很懒,什么都没留下…
展开
-
自测-3 数组元素循环右移问题分数 20
没有必要移动数组 方法 1 #include <iostream> using namespace std; const int N = 1e2+10; int n,m; int a[N]; int main() { cin>>n>>m; for(int i = 0;i < n; i++) cin>>a[i]; m = m%n; for(int i = n - m;i < 2 *原创 2022-05-15 09:55:10 · 263 阅读 · 0 评论 -
7-12 How Long Does It Take (25 分)
7-12 How Long Does It Take (25 分) Given the relations of all the activities of a project, you are supposed to find the earliest completion time of the project. Input Specification: Each input file contains one test case. Each case starts with a line con原创 2022-02-16 15:18:32 · 369 阅读 · 0 评论 -
Prim(小记)
int Prim() { int TotalWeight,dist[MaxSize]; int Parent[MaxSize]; int v,VCount=0; for(v=0;v<Graph->Nv;v++) dist[v] = Graph[0][v]; Parent[0] = -1; dist[0] = 0; VCount ++; while(1) { V = FindMinD.原创 2022-02-15 11:33:39 · 171 阅读 · 0 评论 -
实例6.1 六度空间 (30 分)
“六度空间”理论又称作“六度分隔(Six Degrees of Separation)”理论。这个理论可以通俗地阐述为:“你和任何一个陌生人之间所间隔的人不会超过六个,也就是说,最多通过五个人你就能够认识任何一个陌生人。”如图1所示。 图1 六度空间示意图 “六度空间”理论虽然得到广泛的认同,并且正在得到越来越多的应用。但是数十年来,试图验证这个理论始终是许多社会学家努力追求的目标。然而由于历史的原因,这样的研究具有太大的局限性和困难。随着当代人的联络主要依赖于电话、短信、微信以及因特网上即时通信原创 2022-02-09 21:42:07 · 342 阅读 · 0 评论 -
根据后序和中序遍历输出先序遍历
本题要求根据给定的一棵二叉树的后序遍历和中序遍历结果,输出该树的先序遍历结果。 输入格式: 第一行给出正整数N(≤30),是树中结点的个数。随后两行,每行给出N个整数,分别对应后序遍历和中序遍历结果,数字间以空格分隔。题目保证输入正确对应一棵二叉树。 输出格式: 在一行中输出Preorder:以及该树的先序遍历结果。数字间有1个空格,行末不得有多余空格。 7 2 3 1 5 7 6 4 1 2 3 4 5 6 7 结尾无空行 输出样例: Preorder: 4 1 3 2 6 5 7 .原创 2021-12-11 14:52:41 · 490 阅读 · 0 评论 -
03-树2 List Leaves
#include <stdio.h> #define MaxSize 10 #define Null -1 typedef int Tree; struct TNode{ int Data; Tree Left; Tree Right;; }T[MaxSize],P; int Read(int n) { int cheek[10] = {0}; int root=Null,i=0; char l,r; for(i=0;i<n;i...原创 2021-11-30 15:25:14 · 59 阅读 · 0 评论 -
7-51 两个有序链表序列的合并 (20 分)
已知两个非降序链表序列S1与S2,设计函数构造出S1与S2合并后的新的非降序链表S3。 输入格式: 输入分两行,分别在每行给出由若干个正整数构成的非降序序列,用−1表示序列的结尾(−1不属于这个序列)。数字用空格间隔。 输出格式: 在一行中输出合并后新的非降序链表,数字间用空格分开,结尾不能有多余空格;若新链表为空,输出NULL。 #include <stdio.h> #include <stdlib.h> struct Node{ int Data; s...原创 2021-11-06 13:33:57 · 66 阅读 · 0 评论 -
Maximum Subsequence Sum
#include <stdio.h> int main(void) { int a[10000],i,sum = 0,max = 0,si = 0,n,sum2,j=0,k=0; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%d",&a[i]); if(a[i]<=0) { j++; } if...原创 2021-11-05 14:15:19 · 63 阅读 · 0 评论