现在位置: 首页 > centenary发表的所有文章
  • 11月
  • 13日
综合 ⁄ 共 2433字 评论关闭
        Sigar(全称System Information Gatherer And Reporter,即系统信息收集报表器),它提供了一个开源的跨平台的收集计算机硬件和操作系统信息的API(该API底层接口用C语言编写),本文将演示如何借助Sigar API获取磁盘信息: package com.ghj.packageoftest; import org.hyperic.sigar.FileSystem; import org.hyperic.sigar.FileSystemUsage; import org.hyperic.sigar.Sigar; import org.hyperic.sigar.SigarException; /** * 借助Sigar API获取磁盘信息 * * @author GaoHuanjie */ public class DiskTool { p......
阅读全文
  • 08月
  • 27日
综合 ⁄ 共 1400字 评论关闭
实现的功能是第一次app打开跟随系统语言, 其他则显示用户选择的语言,直接上代码: .h文件 #import <Foundation/Foundation.h> @interface MyLocalString : NSObject +(MyLocalString *)sharedInstance; -(NSString *)MyLocalStringForKey:(NSString *)key; -(void)setMyLanguage:(NSString *)language; @end .m文件 #import "MyLocalString.h" static MyLocalString* localString=nil; NSBundle *languageBundle=nil; @implementation MyLocalString +(MyLocalString*)sharedInstance { static dispatch_once_t onceP......
阅读全文
  • 05月
  • 18日
综合 ⁄ 共 1229字 评论关闭
简单的小例程,留作用从图像中截取部分作为子图像,并保存起来 #include <cv.h> #include <cxcore.h> #include <highgui.h> #include <iostream> using namespace std; void GetImageRect(IplImage* orgImage, CvRect rectInImage, IplImage* imgRect); int main(int argc , char** argv ) { IplImage* src; src = cvLoadImage(argv[1], 0); cvNamedWindow("src", 1); cvShowImage("src", src); IplImage* dst; CvRect rect = cvRect(0, 0, 0.5*src->width, 0.5*src->height); CvSize d......
阅读全文
  • 04月
  • 29日
综合 ⁄ 共 493字 评论关闭
  呃呃呃。很水的一道题,没什么说的,打表,然后筛出来符合条件的解就可以了,多多借助变量之间特殊的关系进行表示会达到简化的目的。 # include<cstdio> # include<iostream> # include<cstring> using namespace std; # define MAX 10000 int hash[MAX+10]; void dabiao() { memset(hash,0,sizeof(hash)); hash[0] = 1; hash[1] = 1; for ( int i = 2;i < MAX;i++ ) { //if (i > MAX/i ) continue;//如果数据大的话,就要这样处理,防止爆int ......
阅读全文
  • 03月
  • 31日
综合 ⁄ 共 1461字 评论关闭
    准备一张名为picture的图片。   在main.xml中:   <LinearLayout     xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="fill_parent"     android:layout_height="fill_parent"     android:background="#000000">   <com.li.bitmap.MyView       android:layout_width="fill_parent"       android:layout_height="wrap_content"/> </LinearLayout>           在MyBitmapDemo.java中:   package com.li.bitmap;   import android.os.Bundle; import android.app.A......
阅读全文
  • 02月
  • 09日
综合 ⁄ 共 3112字 评论关闭
  #-------------------------------------------------------------------------------- # memmap.conf and skyeye.conf are all skyeye's hareware coinfigure files. # memmap.conf is for skyeye-v0.2.5- # skyeye.conf is for skyeye-v0.2.5+ # usually you needn't to chang them. # for example, a AT91's configure file is shown below: #-------------------------------------------------------------------------------- # below is the cpu config info # cpu maybe arm7tdmi or arm720t cpu: arm7tdmi #----------......
阅读全文
  • 01月
  • 28日
综合 ⁄ 共 2018字 评论关闭
下面罗列了各种数据库使用JDBC连接的方式,可以作为一个手册使用。   1、Oracle8/8i/9i数据库(thin模式) Class.forName("oracle.jdbc.driver.OracleDriver").newInstance(); String url="jdbcracle:thinlocalhost:1521rcl"; //orcl为数据库的SID String user="test"; String password="test"; Connection conn= DriverManager.getConnection(url,user,password);   2、DB2数据库 Class.forName("com.ibm.db2.jdbc.app.DB2Driver ").newInstance(); String url="jdbc:db2://localhost:5000/sample"; //sample为你的数据库名 S......
阅读全文
  • 10月
  • 18日
综合 ⁄ 共 3931字 评论关闭
水线段树 A Corrupt Mayor's Performance Art Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 100000/100000 K (Java/Others) Total Submission(s): 538    Accepted Submission(s): 213 Problem Description Corrupt governors always find ways to get dirty money. Paint something, then sell the worthless painting at a high price to someone who wants to bribe him/her on an auction, this seemed a safe way for mayor X to make money. Because a lot of people praised mayor X's painting(of cour......
阅读全文
  • 08月
  • 08日
综合 ⁄ 共 3544字 评论关闭
keycode 8 = BackSpace BackSpace  keycode 9 = Tab Tab  keycode 12 = Clear  keycode 13 = Enter  keycode 16 = Shift_L  keycode 17 = Control_L  keycode 18 = Alt_L  keycode 19 = Pause  keycode 20 = Caps_Lock  keycode 27 = Escape Escape  keycode 32 = space space  keycode 33 = Prior  keycode 34 = Next  keycode 35 = End  keycode 36 = Home  keycode 37 = Left  keycode 38 = Up  keycode 39 = Right  keycode 40 = Down  keycode 41 = Select  keycode 42 = Print  keycode 43 = Execute  keycode 45 = Insert......
阅读全文
  • 04月
  • 06日
综合 ⁄ 共 732字 评论关闭
atoi是字符串转换到整形的函数,用java如何实现呢?看起来简单,陷阱很多,在leetcode网站,这个函数能够写得完全正确的概率只有14%。 atoi的需求是这样的: 如果前面有空格,需要剔除空格; 剔除空格后,第一个字符串如果是+号,认为是正数;如果是-号,认为是负数; 后面的字符如果不是数字,那么返回0,如果是数字,返回实际的数字。遇到不是数字的字符,转换结束。 public class Solution { public int atoi(String str) { //这里要小心,需要判断有效性 if(str==null || str.length() == 0) { return ......
阅读全文
  • 03月
  • 28日
综合 ⁄ 共 728字 评论关闭
Java异常也算常见的情况,现在具体讲解一下Java异常处理的分类有哪些,这样更有助处理Java出现的异常情况。Java异常可分为可检测异常,非检测异常和自定义异常。      非检测异常      非检测异常不遵循处理或声明规则。在产生此类异常时,不一定非要采取任何适当操作,编译器不会检查是否已解决了这样一个异常。例如:一个数组为3个长度,当你使用下标为3时,就会产生数组下标越界异常。这个异常JVM不会进行检测,要靠程序员来判断。有两个主要类定义非检测异常:RuntimeException和Error。      Error子类属于非检......
阅读全文
当你设计你的应用来支持多个屏幕尺寸,你可以基于可用的屏幕空间通过在不同的布局上重用fragment来优化用户体验。 例如,在一个手机上,使用单面板(一次只显示一个fragment)的用户体验更加合适。For example, on a handset device it might be appropriate to display just one fragment at a time for a single-pane user interface. 相反,你可能希望在一个能够展示更多信息的平板上设置并排摆放的fragments。 图 1. 同一个activity在不同的屏幕尺寸上展示的不同的fragment配置。在大尺寸屏幕上,两个fragment并排展示,而......
阅读全文