`
pleasetojava
  • 浏览: 703388 次
  • 性别: Icon_minigender_2
  • 来自: 上海
文章分类
社区版块
存档分类
最新评论
文章列表
// 无向图的一节点到另一节点的最短路径(边数最少的路径)(采用邻接表存储).cpp : Defines the entry point for the console application. // #include "stdafx.h" #include<iostream> #define MAX 100 #define MAXQ 50 using namespace std; struct edgeNode { int no; //边端的序号 char info; //边端的名称 struct edgeNode * next; //下一 ...
// 图的深度优先搜索(采用邻接表存储).cpp : Defines the entry point for the console application. // #include "stdafx.h" #include<iostream> #define MAX 100 using namespace std; struct edgeNode { int no; //边端的序号 char info; //边端的名称 struct edgeNode * next; //下一个 }; struct vexNode { char info ...
// 图的深度优先搜索(采用邻接表存储).cpp : Defines the entry point for the console application. // #include "stdafx.h" #include<iostream> #define MAX 100 using namespace std; struct edgeNode { int no; //边端的序号 char info; //边端的名称 struct edgeNode * next; //下一个 }; struct vexNode { char info ...
// 无向图的广度优先搜索(采用邻接表存储).cpp : Defines the entry point for the console application. // #include "stdafx.h" #include<iostream> #define MAX 100 #define MAXQ 50 using namespace std; struct edgeNode { int no; //边端的序号 char info; //边端的名称 struct edgeNode * next; //下一个 }; struct ve ...
// 无向图的广度优先搜索(采用邻接表存储).cpp : Defines the entry point for the console application. // #include "stdafx.h" #include<iostream> #define MAX 100 #define MAXQ 50 using namespace std; struct edgeNode { int no; //边端的序号 char info; //边端的名称 struct edgeNode * next; //下一个 }; struct ve ...
// 归并排序.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include<iostream> #define N 100 using namespace std; typedef int DataType; //合并data1[begin...mid]和data1[mid+1.end]到data2[begin,end]中,然后复制到data1[begin,end]中 void merge(DataType *data1,Dat ...
// 归并排序.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include<iostream> #define N 100 using namespace std; typedef int DataType; //合并data1[begin...mid]和data1[mid+1.end]到data2[begin,end]中,然后复制到data1[begin,end]中 void merge(DataType *data1,Dat ...
希尔排序 // 希尔排序.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include<iostream> #define N 100 using namespace std; typedef int DataType; void shell_sort(DataType *data,int n) { int i,j,gap; gap = n/2; while(gap>0) { fo ...
希尔排序 // 希尔排序.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include<iostream> #define N 100 using namespace std; typedef int DataType; void shell_sort(DataType *data,int n) { int i,j,gap; gap = n/2; while(gap>0) { fo ...
第K个数 Description 给你一个整数序列和若干个问题,问题是这个序列的第i个元素到第j个元素的片断中的第k大数是什么?比如说给你的序列为(1, 5, 2, 6, 3, 7, 4),问题是(2,5,3),则从第2个元素到第5个元素为(5,2,6,3),排序以后是(2,3,5,6),则第三个数是5。 输入: 第一行为两个整数n,m(1 <= n <= 100 000, 1 <= m <= 5 000),表示序列的元素个数和问题的个数,第二行为n个正整数的序列,每个整数为一个32位整数,两个数之间有一个空格隔开。以后m行为问题,每个问题由三个整数表示i ...
第K个数 Description 给你一个整数序列和若干个问题,问题是这个序列的第i个元素到第j个元素的片断中的第k大数是什么?比如说给你的序列为(1, 5, 2, 6, 3, 7, 4),问题是(2,5,3),则从第2个元素到第5个元素为(5,2,6,3),排序以后是(2,3,5,6),则第三个数是5。 输入: 第一行为两个整数n,m(1 <= n <= 100 000, 1 <= m <= 5 000),表示序列的元素个数和问题的个数,第二行为n个正整数的序列,每个整数为一个32位整数,两个数之间有一个空格隔开。以后m行为问题,每个问题由三个整数表示i ...
小明的数学题Ⅲ Description 小明是个小学五年级的学生,为了早点去看自己爱看的卡通,他想快点把作业做完。可是可恶的数学老师今天却布置了一道难题,小明想了很久也不知道该怎么做。你的任务就是帮小明解决掉这道数学题。 题目是这样子的,有两个实数a,b,计算a/b,要求保留小数点后面n 位(0<=n<=100,四舍五入)。 输入: 第一行是一个整数K,表示有多少个测试用例,以后每行一个测试用例,每行有三个数a,b,n。a,b都是形如1.02或者2的数,不采用科学计数法表示,也不会有.5或者2.之类的方法表示。 输出: 每行输出一个测试用例的结果 Sample ...
小明的数学题Ⅲ Description 小明是个小学五年级的学生,为了早点去看自己爱看的卡通,他想快点把作业做完。可是可恶的数学老师今天却布置了一道难题,小明想了很久也不知道该怎么做。你的任务就是帮小明解决掉这道数学题。 题目是这样子的,有两个实数a,b,计算a/b,要求保留小数点后面n 位(0<=n<=100,四舍五入)。 输入: 第一行是一个整数K,表示有多少个测试用例,以后每行一个测试用例,每行有三个数a,b,n。a,b都是形如1.02或者2的数,不采用科学计数法表示,也不会有.5或者2.之类的方法表示。 输出: 每行输出一个测试用例的结果 Sample ...
区间图着色问题 问题描述:假设要用很多个教室对一组活动进行调度。我们希望使用尽可能少的教室来调度所有活动。请给出一个算法,来确定哪一个活动使用哪一间教室。 这个问题也被称为区间图着色问题,即相容的活动着同色,不相容的着不同颜色,使得所用颜色数最少。 //贪心算法 #include "stdafx.h" #include<iostream> #define N 100 using namespace std; struct Activity { int number; //活动编号 int begin; //活动开始时间 int end; ...
区间图着色问题 问题描述:假设要用很多个教室对一组活动进行调度。我们希望使用尽可能少的教室来调度所有活动。请给出一个算法,来确定哪一个活动使用哪一间教室。 这个问题也被称为区间图着色问题,即相容的活动着同色,不相容的着不同颜色,使得所用颜色数最少。 //贪心算法 #include "stdafx.h" #include<iostream> #define N 100 using namespace std; struct Activity { int number; //活动编号 int begin; //活动开始时间 int end; ...
Global site tag (gtag.js) - Google Analytics