编程技巧
源码超级联盟
这个作者很懒,什么都没留下…
展开
-
多线程同步调试1
主类public class Main { public static void main(String args[]){ Thread a = new Thread(new TreadAdd()); Thread b = new Thread(new TreadAdd()); Thread c = new Thread(new TreadAdd());原创 2014-03-04 21:59:16 · 576 阅读 · 0 评论 -
多源最短路径弗洛伊德算法(java)不含具体路径
package hg;import java.util.Arrays;public class Florid { public int n =5; public static void main(String[] args){ double a[][] = {{0.0,3.0,8.0,Double.MAX_VALUE,-4.0}, {原创 2014-07-22 09:35:36 · 797 阅读 · 0 评论 -
哈夫曼编码(java)
public class BinaryTree implements Comparable{ int key; char data; //左子树 BinaryTree left; //右子树 BinaryTree right; public BinaryTree(){ } public Bina原创 2014-07-23 09:50:00 · 538 阅读 · 0 评论 -
求二叉树中节点的最大距离
如果我们把二叉树看成一个图,原创 2014-07-24 09:49:08 · 422 阅读 · 0 评论 -
四皇后问题的代码实现(java)
package hg;/*** * 求解四皇后问题(回溯法) * @author user * */public class hjk { private int[][] s = new int[4][4]; private int[] arr = new int[4]; public void Queen(int i){ if(原创 2014-06-20 11:41:22 · 2993 阅读 · 0 评论 -
判断是否是回文数字(java版)
public class Huiwenshuzi { public boolean isHui(int j){ if(reverse(j)==j) { return true; } return false; } public int reverse(int j){原创 2014-06-20 11:22:37 · 792 阅读 · 0 评论 -
玩转elastic_search
玩转elastic_search1. 使用elastic_search的初衷 由于数据量挺大(500w以上),使用mysql查询速度有些慢,虽然创建了索引依然有些慢开始研究使用elastic_search。发现上手非常容易,网上资料也挺多资料,一个小的需求研究下两天就搞定了。至于其中的原理让人无限向往。2.搭建es环境 搭建环境超级简单,下载代码打包,下载...原创 2018-09-27 16:18:26 · 134 阅读 · 0 评论 -
异构系统间的调用
一.需求背景 算法团队使用python作为开发语言,web系统的开发人员使用java,web系统提供了一些页面操作,用户点击 按钮之后,java调用python脚本进行处理。二.错误的选择 这个项目之前,笔者并没有过java系统调用python的经验,并且项目时间紧张,使用了最直接的调用方式,就是本地环境调用java脚本。代码如下:public stat...原创 2018-12-03 12:05:06 · 1046 阅读 · 0 评论 -
java的两种文件拷贝方式
一.基础三种IO方式1.传统IO方式,基于流模型实现,提供了File抽象,输入输出流等,交互方式是同步,阻塞的方式,也就是说在读写动作完成之前,线程一直阻塞在那里。2.NIO 引入了Channel,Selector,Buffer等新的抽象,可以构建多路复用的,同步非阻塞的IO程序3.AIO 异步非阻塞 二.实现1.利用java.io.类库,直接为源文件构建一个Fil...转载 2018-12-03 16:21:59 · 169 阅读 · 0 评论 -
求二进制包含的1的个数(位操作)
public class Qiu { int count(byte a){ int num =0; while(a!=0){ num = num + (a&0x01); System.out.println( num); a=(byte) (a>>1); } return num;原创 2014-07-02 09:33:44 · 510 阅读 · 0 评论 -
汉诺塔的实现
汉诺塔是大学遇见的第一个使用递归原创 2014-06-27 17:40:17 · 465 阅读 · 0 评论 -
使用概率的思想求圆周率
public class Mengtekaluo { public static void main(String[] args){ Mengtekaluo mengte = new Mengtekaluo(); System.out.println(mengte.pai()); } public doubl原创 2014-06-25 18:01:06 · 712 阅读 · 0 评论 -
多线程同步的前提
多线程同步的前提是多个线程使用同一个锁:主类public class Main { public static void main(String args[]){ TreadAdd t = new TreadAdd(); Thread a = new Thread(t); Thread b = new Thread(t); Thread c = ne原创 2014-03-04 22:26:45 · 521 阅读 · 0 评论 -
BigInteger转化为Long
今天出的Bug在以往调试这个部分时并没有出现数据库id为bigint类型的,取出之后转化为Long型报错id并是很大5000多原因不明,但问题已经解决了解决的方式为BigInteger a = BigInteger(map.get("id").toString);Long value = a.getLongValue;原创 2014-03-04 22:44:47 · 4927 阅读 · 0 评论 -
ExtJs
整了一天的extjs框架,老是报错这样一个错误events 找不到或者不是一个对象这个错误,在IE6,8经常见到。加上这个就好了if(Ext.isIE){ Ext.enableGarbageCollector=false; }原创 2014-03-18 18:38:05 · 418 阅读 · 0 评论 -
寻找汉密尔顿回路(java版)
package hg;public class Hanmierdun { //结点的个数 public int n =5; public int b[] = new int[5]; //是否已经经过该结点 public boolean used[] = new boolean[5]; //是否已经全部走过 public bo原创 2014-07-15 14:36:57 · 2494 阅读 · 0 评论 -
马踏棋盘(有问题的且不成熟的程序)
//将棋盘上的每个位置都走一遍public class Mataqipan { public int zou(int position[][],int m,int n,int count){ position[m][n]=count; System.out.println(count); if(count==64){原创 2014-06-24 17:37:08 · 471 阅读 · 0 评论 -
使用递归的方法求数组的最小值
public class MixReCursion { public int getMin(int arr[],int pos,int n){ int n1,n2,n3; if(n==1){ return arr[pos]; } else{ if原创 2014-06-24 09:34:25 · 1088 阅读 · 0 评论 -
着色问题的代码实现(java版)使用回溯法和贪心思想
着色问题描述:原创 2014-07-17 13:56:47 · 1875 阅读 · 0 评论 -
python编程练习
1.求101到201之间的素数总数 h=0loop =1total=0for m in range(101,201): print('%-4d' % m) h= int(sqrt(m+1)) for i in range(2,h+1): if m%i==0: loop=0 break if loop==1: total...原创 2018-12-03 17:14:24 · 219 阅读 · 0 评论