现在位置: 首页 > sain发表的所有文章
  • 10月
  • 14日
综合 ⁄ 共 1822字 评论关闭
HBase基本的CRUD操作就不多介绍了,无非就是Put,Get,Delete三个类的运用。 本文相当于是阅读HBase权威指南的总结。 一、扫描(Scan) 现在看一下扫描技术,这种技术类似于关系型数据库的游标(cursor),并利用到了HBase底层顺序存储的特性。 使用扫描的一般步骤是: 1、创建Scan实例 2、为Scan实例增加扫描的限制条件 3、调用HTable的getScanner()方法获取ResultScanner对象,如果通过HTablePool的方式,则是调用HTablePool的getScanner方法。(注意,HTable类实现了HTableInterface接口,这个接口用于与单个HBase表通信。) 4......
阅读全文
  • 12月
  • 31日
综合 ⁄ 共 665字 评论关闭
贪心 要想减少的分数最小,所以要在最后完成时间之前把扣分最多的要完成,所以按照扣除分数的大小排序,这里有个问题,就是排完序后面的规定时间可能小于前边的,选择前边作业的完成时间要尽量大,为后面的作业留下时间。 #include<stdio.h> #include<string.h> #include<stdlib.h> int time[1010]; struct op { int t,cont; }p[1010]; int cmp(const void *a,const void *b) { struct op *c,*d; c=(struct op *)a; d=(struct op *)b; if(c->cont!=d->cont) return d->cont-c->cont; ......
阅读全文
  • 11月
  • 07日
综合 ⁄ 共 7861字 评论关闭
算法描述 摘自:对应中文:哈弗曼编码算法 英文:A simple example of Huffman coding on a string You’ve probably heard about David Huffman and his popular compression algorithm. If you didn’t, you’ll find that info on the Internet. I will not bore you with history or math lessons in this article. I’m going to try to show you a practical example of this algorithm applied to a character string. This application will only generate console output representing the code values for the symbols......
阅读全文
  • 10月
  • 13日
综合 ⁄ 共 992字 评论关闭
0-1背包模型,每个人的决策为装 0-j 个storage,j为当前剩余storage的数量 先求出最大的L,再用这个L重新做一次dp,找出最小的Y Run Time: 0.016s #define UVa "9-9.10163.cpp" //Storage Keepers char fileIn[30] = UVa, fileOut[30] = UVa; #include<cstring> #include<cstdio> #include<algorithm> #include<vector> #include<iostream> using namespace std; //Global Variables. Reset upon Each Case! const int maxm = 30 + 5, maxn = 100 + 5, INF = 1<<30; int n, m, p[maxm......
阅读全文
  • 07月
  • 11日
综合 ⁄ 共 1292字 评论关闭
  本文提供了一个方法,让C++源码和C#源码一起编译链接成一个单一的Assembly。  由于C++提供了IJW方法,允许将旧有C++代码也编译成托管代码,因此这篇小文可以用极小的工作量来彻底解决所有C++遗留代码移植到.NET的问题。  这个方法,再加上前次的小文《您也使用托管C++吗?》,就可以把C++遗留代码移植到.NET的所有方法一网打尽了。   好了,言归正传。  假设一个很简单的C++程序,它只有一个函数: //c.h#pragma onceint sqr(int n);   //c.cpp#include "c.h"int sqr(int n){  return n*n;}   为了能让它与C#共同工......
阅读全文
  • 07月
  • 06日
综合 ⁄ 共 534字 评论关闭
我们有这样的经验,在VC6.0、VS2003下使用Use MFC in a shared DLL选项编译出来的程序,如果在一台纯洁的机器上运行,会弹出警告,提示我们缺少某些dll。我们乖乖的把那些库收集起来,打包的时候裹到一起就OK了。   可是,在VS2005下,好日子不再有了。在VS2005下使用Use MFC in a shared DLL选项编译出来的程序,在Windows 2003或Windows XP下运行,系统会警告:“应用程序配置不正确,应用程序因此未能启动,重新安装也许会解决此问题。”我们认为问题不大,按照以往经验,把MFC开头的dll拿来,放在程序目录下...可是,为什么警告依......
阅读全文
  • 05月
  • 28日
综合 ⁄ 共 3678字 评论关闭
volatile提醒编译器它后面所定义的变量随时都有可能改变,因此编译后的程序每次需要存储或读取这个变量的时候,都会直接从变量地址中读取数据。如果没有volatile关键字,则编译器可能优化读取和存储,可能暂时使用寄存器中的值,如果这个变量由别的程序更新了的话,将出现不一致的现象。 下面举例说明。在DSP开发中,经常需要等待某个事件的触发,所以经常会写出这样的程序: short flag; void test() { do1(); while(flag==0); do2(); }     这段程序等待内存变量flag的值变为1(怀疑此处是0,有点疑问,)之后才运行do2()。变量flag......
阅读全文
  • 05月
  • 21日
综合 ⁄ 共 12879字 评论关闭
package com.zxh.customer.bean; public class Parter {  private Long partyId;    private String partyName;  public Long getPartyId() {   return partyId;  }  public void setPartyId(Long partyId) {   this.partyId = partyId;  }  public String getPartyName() {   return partyName;  }  public void setPartyName(String partyName) {   this.partyName = partyName;  }      }       package com.zxh.customer.bean; import java.io.Serializable; import java.util.List; import com.zxh.customer.bean.Parter; pub......
阅读全文
  • 05月
  • 19日
综合 ⁄ 共 16337字 评论关闭
8x8JPEG文件格式分析 ­ JPEG的文件数据 ­ Offset      0  1  2  3  4  5  6  7   8  9  A  B  C  D  E  F ­ 00000000   FF D8 FF E0 00 10 4A 46  49 46 00 01 01 01 00 60   鮂F??.JFIF.....` ­ 00000010   00 60 00 00 FF DB 00 43  00 08 06 06 07 06 05 08   .`..鮂F?C........ ­ 00000020   07 07 07 09 09 08 0A 0C  14 0D 0C 0B 0B 0C 19 12   ................ ­ 00000030   13 0F 14 1D 1A 1F 1E 1D  1A 1C 1C 20 24 2E 27 20   ........... $.' ­ 00000040   22 2C 23 1C 1C 28 37 29  2C 30 31 34 34 34 1F 27   ",#........
阅读全文
  • 05月
  • 12日
综合 ⁄ 共 2320字 评论关闭
一般来说,网络编程我们只需要调用一些封装好的函数或者组件就能完成大部分的工作,但是一些特殊的情况下,就需要深入的理解 网络数据包的结构,以及协议分析。如:网络监控,故障排查等……   IP包是不安全的,但是它是互联网的基础,在各方面都有广泛的应用。由IP协议衍生的协议族有10数种(据我所知),以后还会出现 更多的基于IP的协议…   先从实际出发吧! 一般我们在谈上网速度的时候,专业上用带宽来描述,其实无论说网速或者带宽都是不准确的,呵呵。比如:1兆,512K…… 有些在学校的学生,也许会有疑问,明明我的业......
阅读全文
  • 05月
  • 02日
综合 ⁄ 共 1172字 评论关闭
我的第一道强连通 #include<cstdio> #include<vector> #include<algorithm> using namespace std; vector<int> ljb[200000],nljb[200000],jh[200000]; int n,m,i,x,y,wz,zn,ans,bcnt,dfn[200000],belong[200000], instack[200000],low[200000],dindex,stap[200000],stop; void tarjan(int i){ dfn[i]=low[i]=++dindex; instack[i]=1; stap[++stop]=i; vector<int>::iterator iv; for (iv=ljb[i].begin();iv!=ljb[i].end();iv++){ if (!dfn[*iv]){ tarjan(......
阅读全文
  • 04月
  • 30日
综合 ⁄ 共 5275字 评论关闭
系统的进程通信,我们平时也经常用到,比如使用WifiManager,TelephonyManager,ConnectivityManager等等,他们就是通过系统的进程通信获取到的,获取系统服务的时候,需要用到getSystemService方法, 比如:ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);  我们知道activity的继承关系为: activity---------->ContextThemeWrapper---------->ContextWrapper---------->Context Context是个抽象类,在这个类中有个抽象方法,  public abstract Object getSystemServi......
阅读全文