摘要: 2、Dijkstra算法介绍 算法特点: 迪科斯彻算法使用了广度优先搜索解决赋权有向图或者无向图的单源最短路径问题,算法最终得到一个最短路径树。该算法常用于路由算法或者作为其他图算法的一个子模块。 算法的思路 Dijkstra算法采用的是一种贪心的策略,声明一个数组dis来保存源点到各个顶点的最短距 阅读全文
posted @ 2018-04-10 10:23 Syiren 阅读(147) 评论(0) 推荐(0) 编辑
摘要: import java.util.*;public class main{ public static void main(String[] args) { int[] a = new int[]{12,23,1,3,7,2}; Arrays.sort(a); System.out.println( 阅读全文
posted @ 2018-04-02 21:19 Syiren 阅读(890) 评论(0) 推荐(0) 编辑
摘要: import java.util.Scanner;public class Main{ public static void main(String args[]){ Scanner scanner=new Scanner(System.in); int W=0; int H=0; W = scan 阅读全文
posted @ 2018-04-02 16:13 Syiren 阅读(250) 评论(0) 推荐(0) 编辑
摘要: System.in是输入的意思。Scanner s = new Scanner(System.in);是新建一个扫描器,扫描你输入的内容。s.nextInt()是扫描到的你输入的int类型的值。int x是将扫描到的你输入的int类型的值赋到x上。 18位身份证的编码规则是: 前1、2位数字表示:所 阅读全文
posted @ 2018-04-01 16:40 Syiren 阅读(660) 评论(0) 推荐(0) 编辑
摘要: 每一个链表实际上就是由多个节点所组成的 阅读全文
posted @ 2018-03-31 21:39 Syiren 阅读(102) 评论(0) 推荐(0) 编辑
摘要: public class Solution { public int NumberOf1(int n) { int count=0; String str=Integer.toBinaryString(n); for(int x=0;x<str.length();x++) { if(str.char 阅读全文
posted @ 2018-03-31 17:37 Syiren 阅读(251) 评论(0) 推荐(0) 编辑
摘要: 类似于青蛙跳台阶,当n=1时,只有一种横向排列的方式。当n等于二时,2*2有两种选择,横向或者是竖向。当n等于3的时候对于2*3来说,如果选择的是竖向排列,则剩下的就是2*2排列,如果选择的是横向,则对于2*n剩下的则只有1*n的一种选择。所以依次类推,找到迭代RectCover(target-1) 阅读全文
posted @ 2018-03-31 17:22 Syiren 阅读(802) 评论(0) 推荐(0) 编辑
摘要: 斐波那契数列指的是这样一个数列: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233,377,610,987,1597,2584,4181,6765,10946,17711,28657,46368。 可以观察到,从第3个数开始,每个数的值都等于前连个数 阅读全文
posted @ 2018-03-31 16:39 Syiren 阅读(6015) 评论(0) 推荐(0) 编辑
摘要: 代码块:普通代码块、构造快、静态块、同步代码块(多线程) 普通代码块:{} 就是为了防止在方法里面在编写代码过多时有可能产生的变量过多产生重复。 构造快: 将代码块写在类里面,构造快调用优先于构造方法,并且重复调用(但是没用) 静态块:static{}(可能会用,编写测试) 情况一:静态块优先于构造 阅读全文
posted @ 2018-03-31 11:39 Syiren 阅读(245) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2018-03-31 11:25 Syiren 阅读(207) 评论(0) 推荐(0) 编辑