`
文章列表
当使用System.getProperty("os.name");时请务必检查开发环境是否以某种系统兼容模式运行的

一摞烙饼

1.有一些服务员会把上面的一摞饼子放在自己头顶上(放心,他们都戴着洁白的帽子),然后再处理其他饼子,在这个条件下,我们的算法能有什么改进? int[] cakeArray; CPrefixSorting sorting; for(int i=0;i<cakeArray.length;i++) { 找出cakeArray[0:i]中的最大者cakeArray[i_max]; 找出cakeArray[i+1:cakeArray.length-1]中的最小者cakeArray[i_min]; if(cakeArray[i_max]<=cakeArray[ ...
Build工程时出现 fatal error C1033: cannot open program database '' Solution: 将VC或者VS2003的运行模式设置为"Run this program in compatibility mode for Windows Vista"
getTabComponentAt() returns the custom component you might add as the tab title. getComponentAt() returns the contents of a tab. The tab component is the component that renders the tab--not the component that displays in the pane. // In this case the look and feel renders the title for the tab. t ...

Java调用Linux命令行

    博客分类:
  • Java
public String executeCmds(String[] cmds) { String result = ""; File wd = new File("/bin"); Process proc = null; try { proc = Runtime.getRuntime().exec("/bin/bash", null, wd); } catch (IOException e) { e.printStackTrace(); ...
在Linux下对ATA设备的读写操作,经常会用到系统read函数和write函数,虽然这样用可以使得函数的复用性增强了,但是read函数和write函数在对ATA设备操作时经常出现异常现象,可能做近百次的write或者read之后,ATA设备就会丢失,从而出现错误。 建议:使用scsi_read和scsi_write
#include <sys/stat.h> #include <stdio.h> #include <time.h> #define FILENAME "test.lod" int main(void) { struct stat statbuf; FILE *stream; /* open a file for update */ if ((stream = fopen(FILENAME, "r")) == NULL) { fprintf(st ...
在不知道源字符串和目的字符串长度时候,千万不要使用strcpy,尤其是目的字符串是struct中的一个成员的时候! 今天改了一天的程序,在jni中改动了C的代码,但是不论怎么改动,输出结果中都无任何显示,最后明白了,改动后编译出的.so文件没有拷贝到/usr/lib中去,也就是说Java还在调用原先的C库。对自己真是无语了。。。 原因:没有对在程序和makefile的改动及一些拷贝操作做记录!

rmi动态下载

    博客分类:
  • Java
服务器端运行命令rmiregistry,然后java HelloServer(这两条命令都是在/root/Test/server/目录下运行的) 客户端运行命令java -Djava.rmi.server.codebase=http://192.168.2.51/ HelloClient 192.168.2.51 其中最后192.168.2.51是HelloServer所在host的ip地址,-Djava.rmi.server.codebase=http://192.168.2.51/是HelloImpl_Stub.class所在位置 在服务器端的/root/Test/目录下运行命令rmire ...

rmi小问题

    博客分类:
  • Java
在进行rmi之前要保证client和server端的防火墙都关闭 问题:在Server端运行完rmiregistry之后,运行java *Server出现一个错误java.lang.ClassNotFoundException: *Impl_Stub 解决方案: 1、在*Server.class所在的目录下,运行rmiregistry 2、在linux下java -Djava.rmi.server.codebase=file:/root/Test/server/ *Server,其中/root/Test/server/为*Impl_Stub.class文件所在的目录;在Windows下jav ...
我所遇到的活动安排问题分为两类 一、求最大相容子集合问题,采用贪心算法,证明很简单 二、求最小的相容子集合数目的问题 对于第二种问题,可以转换为图的最小着色数问题,但是由于该问题的特殊性(各个活动的时间安排都是一维的) 解法1、将各个活动按照开始时间从小到大排列,遍历每一个活动,当前活动的颜色取决于它前面活动的颜色,时间复杂度为O(n^2);若采用堆的数据结构来存储前面活动的颜色,时间复杂度可以降低为O(n*lgn) 解法2、查找一个时间点,是包含这个时间点的活动区间数目最大,那么这个最大的数即为所求 解法3、将所有活动的开始时间(B[i])、结束时间(E[i])按照从小到大排序,得到一个2*N ...
问题:在一个高楼里面,电梯只在某一个楼层停,这个政策还是不太人性化。如果电梯会在k个楼层停呢? 解答:以k=2为例 电梯在2个楼层停,设为楼层A和楼层B(A<B),那么目的地在楼层1至楼层(A+B)/2的人会选择在楼层A下电梯,目的地在楼层(A+B)/2+1至顶楼的人会选择在楼层B下电梯;由此问题分解为两个子问题,1楼至楼层(A+B)/2和楼层(A+B)/2+1至顶楼,那么每个子问题都可以采用书中的方法进行求解。
背景:Windows下的分区皆为NTFS 1、下载openSUSE-11.3-DVD-i586.iso或者openSUSE-11.3-DVD-x86_64.iso 2、解压缩,将镜像中的文件拷贝至D:\suse目录下;将镜像文件拷贝至C:\根目录下,并改名为suse.iso 3、系统管理员用户下运行D:\suse目录下的openSuse1 ...
JNI定义如下 package jni; public class Test { public native void addOne(); public native int getGlobalValue(); } JNI对应的C代码 #include"jni_Test.h" #include <stdio.h> int value = 1000; JNIEXPORT void JNICALL Java_jni_Test_addOne(JNIEnv *env, jobject obj) ...
个人感觉饮料供应问题是符合贪心选择性的 VolumeTotalCountHappiness2^0   TC0_0     H0_0     2^0   TC0_1     H0_1     ...   ...       ...      2^0   TC0_n0    H0_n0    2^1   TC1_0     H1_0     ...   ...       ...      2^M ...
Global site tag (gtag.js) - Google Analytics