现在位置: 首页 > nair发表的所有文章
  • 11月
  • 10日
综合 ⁄ 共 505字 评论关闭
这些题比较考验边界条件 Find Minimum in Rotated Sorted Array class Solution { public: int findMin(vector<int> &num) { int left = 0, right = num.size()-1; while(num[left] > num[right]){ int mid = (left+right) >> 1; if(num[mid] < num[right]) right = mid; else left = mid+1; } return num[left]; } }; Find Minimum in Rotated Sorted Array II class Solution ......
阅读全文
  • 04月
  • 25日
移动开发 ⁄ 共 2703字 评论关闭
1.一些常用的数据结构 hardware/libhardware/include/hardware.h中 定义了三个重要的结构: struct hw_module_t; //模块类型 struct hw_module_methods_t;   //模块方法 struct hw_device_t;   //设备类型 hw_module_t中包含结构hw_module_methods_t hw_module_methods_t只有一个唯一的Open方法,如下:   int (*open)(const struct hw_module_t* module, const char* id,struct hw_device_t** device); struct hw_device_t中包含hw_module_t结构和一个close方法如下:   int (*close)(struct hw_device_t* device)......
阅读全文
  • 01月
  • 07日
综合 ⁄ 共 1025字 评论关闭
        题目大意:给你一个单词表,然后统计出以某个字符串为前缀的单词数量(单词本身也是自己的前缀).         解题思路:这是一道赤裸裸的Trie树简单题,只要建好Trie树就可以了。 请看代码: #include<iostream> #include<cstring> #include<string> #include<cstdio> #include<cmath> #include<algorithm> #include<queue> using namespace std ; const int MAXN = 1e5 + 7 ; char s[100] ; struct Tnode // 建立 节点 结构 { int count ; Tnode *next[27] ; } ; Tn......
阅读全文
  • 10月
  • 05日
编程语言 ⁄ 共 740字 评论关闭
zlib简单示例代码,compress、uncompress: #include <iostream> #include <string> #include <zlib.h> #include <zconf.h> using namespace std; int main(int argc, char *argv[]) { // unsigned char szSrc[] = "test the compression and uncompression of zlib."; unsigned long nSrcLen = sizeof(szSrc); unsigned char szZip[1024] = {0}; unsigned long nZipLen = 1024; compress(szZip, &nZipLen, szSrc, nSrcLen); // unsigned char szUnZip[1024] = {0}; unsigned long n......
阅读全文
  • 05月
  • 28日
综合 ⁄ 共 4471字 评论关闭
转载请注明原文网址: http://www.cnblogs.com/xianyunhe/archive/2011/09/02/2163842.html 目前很多软件都是要出口到多个国家,因此,为软件提供多国语言支持就成为了一个基本条件。为软件提供多国语言的支持的具体实现方法有很多,但基本原理都差不多,就是实现代码和语言包的独立,代码根据设定的语言选择语言包。 其中,MFC的资源文件就提供了对多国不同语言的支持功能,如果使用MFC开发,直接用资源文件自带的多国语言支持,可以省去不少的麻烦。 下面就介绍给MFC程序添加中英文的支持,开发环境为VS2010。 1.  新建工程 新......
阅读全文
  • 05月
  • 18日
综合 ⁄ 共 1123字 评论关闭
Queue: 特点:1)队头取走元素,队尾插入元素,其他元素不能访问,因此无遍历行为 本质:使用deque封闭前端入口和底端出口   下面程序是关于queue的实现 #include<iostream> #include<string> #include<vector> #include<iterator> #include<queue> using namespace std; template<class T,class Sequence=deque<T> > class MaQueue {  friend bool operator==_STL_NULL_TMPL_ARGS(const MaQueue& x,const MaQueue& y)  //friend bool operator==(const MaQueue& x,const M......
阅读全文
  • 05月
  • 17日
综合 ⁄ 共 1260字 评论关闭
原文链接:http://blog.csdn.net/bopzhou/article/details/6063163/ C、C++中没有提供 直接获取数组长度的函数,对于存放字符串的字符数组提供了一个strlen函数获取长度,那么对于其他类型的数组如何获取他们的长度呢?其中一种方法是使 用sizeof(array) / sizeof(array[0]), 在C语言中习惯上在 使用时都把它定义成一个宏,比如#define GET_ARRAY_LEN(array,len) {len = (sizeof(array) / sizeof(array[0]));} 。而在C++中则可以使用模板 技术定义一个函数,比如: template <class T> int getArrayLen(T& array) { r......
阅读全文
  • 04月
  • 23日
综合 ⁄ 共 1145字 评论关闭
动态规划, dp[j] 表示1-N中任意挑选几个元素加起来和为 j 的种类数,所以dp[j]=∑dp[ j - i ],初始化dp[1]=1; code /* ID: yueqiq LANG: C++ TASK: subset */ #include <set> #include <map> #include <ctime> #include <queue> #include <cmath> #include <stack> #include <limits> #include <vector> #include <bitset> #include <string> #include <cstdio> #include <cstring> #include <fstream> #include <string.h> #include <......
阅读全文
在前面的话: 博主新开了个人站点,你也可以在这看到这篇文章,点击打开链接 自到公司报道以后,我们几个以后在ASB的工作方向和开发知识已然基本确定了。看来要暂时告别OO,告别Java,告别Web Dev了。好好加强C语言的编程能力,尽快了解未来不久将要接触的几块板子已成当务之急。驱动开发的方向让我感到兴奋,从来没有接触过这么底层的东西,回首那些年我还青涩的日子,打心底的感觉写驱动的都是不得了的大牛所干的事情,一想到自己就马上要加入到这个战线中我的小心脏怎么能不又惊又颤呢。 也许在ASB的这近一年的时间会让我更加......
阅读全文
  • 03月
  • 16日
综合 ⁄ 共 330字 评论关闭
组播是一种一对一组的通信机制,注意这种通信方式与广播通信不同,广播通信时一对所有的主机的通信机制,组播仅仅是一对一组主机的通信机制。      如果主机想获得多播报文,相邻的路由器也必须支持IGMP,如果想获得Internet上的多播报文,主机到Server的这个路径中所遇到的路由器必须全部支持IGMP,路由器还必须支持源发现协议,如MSDP,PIM_DM,PIM_SM等。    组播是分级的:level0 不支持组播;level1仅支持向多播组发送数据而不支持接受多播组的数据,就像网络电视一样;level3全面支持组播;    详细参考:http://blog.csdn.n......
阅读全文
  • 02月
  • 15日
综合 ⁄ 共 21字 评论关闭
    任意多边形三角剖分,终于完成了。^_^
阅读全文
  • 02月
  • 03日
综合 ⁄ 共 542字 评论关闭
import  java.io.*; public  class IO2 { public static void main(String []args){       try { File f1= new File("F:" + File.separator + "doto.txt");      //文件路径     File f2= new File ("f:" + File.separator + "outto.txt");     InputStream input =null;//声明对象     OutputStream output = null;          input = new  FileInputStream(f1);//实例化对象     output=  new FileOutputStream(f2,true);     if(f1!=null&&f2!=null){         int temp=0;         while((temp=input.read())!=-1){//文......
阅读全文