public class MatrixChainOrder {
int[] p;
int[][] m;
int[][] s;
int length;
public MatrixChainOrder(int[] p,int[][] m,int[][] s){
this.p = p;
this.length = p.length/2;
this.m = m;
this.s = s;
init();
clac();
printM();
}
public void init(){
for (int i=0;i<length;i++){
m[i][i] = 0;
}
}
public void clac(){
for (int i=1;i<length;i++){
for (int j=0;j<length-i;j++){
int r = j+i;
int t = Integer.MAX_VALUE;
for (int k = j;k<r;k++){
int temp = m[j][k] + m[k+1][r] + p[j*2]*p[k*2+1]*p[r*2+1];
if (t > temp){
t = temp;
m[j][r] = temp;
}
}
}
}
}
public void printM(){
......
做这个问题开始我的思路是正确的,可是,只是想一起打印100-10000的,后来才发现不可以。。
public class shui
{
public static void main(String[] args)
{
System.out.println("开始输出水仙花数");
/*打印100-1000以内的水仙花。*/
int b,s,g;
for(int i=100;i<1000;i++)
{
b=i/100;
s=i%100/10;
g=i%10;
if(b*b*b+s*s*s+g*g*g==i)
{
System.out.println("100—1000的水仙花为 :"+i);
}
}
/*1000到10000的水仙花数*/
int w , x , z,q;
for(int i=1000 ; i<10000 ; i++)
{
w = i / 1000;
x=(i-w*1000)/100;
z= ......
转帖自: http://hi.baidu.com/java4me/blog/item/76ca8407338ed2720208818d.html
构造方法摘要
Object()
方法摘要
protected Object clone()
创建并返回此对象的一个副本。
boolean equals(Object obj)
指示某个其他对象是否与此对象“相等”。
protected void finalize()
当垃圾回收器确定不存在对该对象的更多引用时,由对象的垃圾回收器调用此方法。
Class<? extends Object> getClass()
返回一个对象的运行时类。
int hashCode()
返回该对象的哈希码值。
void notify()
唤醒在此对象监视器上等待的单个线程。
void notifyAll()
&nbs ......
zhaoqian.java
public class zhaoqian
{
public static void main(String[] args)
{
int m[]={25,10,5,1};
int n=99;
int[] num=new int[m.length];
num=zhaoqian(m,n);
System.out.println(n+"的找钱方案:");
for(int i=0;i<m.length;i++)
System.out.println(num[i]+"枚"+m[i]+"面值");
}
public static int[] zhaoqian(int m[],int n)
{
int k=m.length;
int[] num=new int[k];
for(int i=0;i<k;i++)
{
num[i]=n/m[i];
n=n%m[i];
}
return num;
}
}
Activearr.java
public class Activearr
{
public static int greedselector(int [] s,int [] f,boolean [] a)
{
int n = s.length - 1;
a [0] = true;
int j = 1;
int count = 1;
for (int i = 1;i <= n;i ++)
{
if (s [i] > ......
一、什么是UML
统一建模语言(UML是 Unified Modeling Language的缩写)是一种应用于面象对象软件开发过程的建模语言,是一种简单、直观的表示符号和标准,UML只是分析和设计过程中分析方法和设计思想的体现和表示,它只体现你所建模的系统会是什么样的,但它并不能明确告诉你你的系统是怎么实现的,它不是分析和设计的方法或思想它只是一种表示方式,你可以通过UML把你在设计
模式等方面掌握的设计思想展示出来。
二、UML的功能
可视化功能:促进对问题的理解和解决,方便开发人员之间交流,可以较为容易发现设计草图的逻辑错误,保证最后完成的软件能够按要求运行。
说明功能:UML是一种通用的、精确的、没有歧义的通信机制,很适合对系统进行说明。系统的整体设计可以指导软件开发的过程,由于重要的决定均在编码之前做出,所以可以减少低质量的代码,进一步降低开发成本。
建造功能:uml只是面象对象分析、设计思想的体现,和具体的实现平台无关,用UML建模和设计的系统可以用java或.net来实现。通过UML可以看到总体的图像,可以均衡掉配系统的资源,使系统更有效率。因为系统的设计首先完成,所以可以很容易发现可以复用的代码,代码能够很 ......
在Java中可以通过System.currentTimeMillis()或者System.nanoTime() (JDK>=5.0) 方法获得当前的时间的精确值。但是通过阅读Javadoc,我们发现这两个方法并不一定保证得到你所期望的精度。先来看System.currentTimeMillis():
Returns the current time in milliseconds. Note that while the unit of time of
the return value is a millisecond, the granularity of the value depends on the
underlying operating system and may be larger. For example, many operating
systems measure time in units of tens of milliseconds.
诚如上面所说返回值的粒度依赖于底层操作系统,那么它在不同的平台上到底能提供是么样的精度,是否像函数名所写的那样真正
精
确到1毫秒呢?看下面一段测试程序:
public class ClockAccuracyTest {
public static void main(String args[]) {
SimpleDateFormat formatter = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss:SSS");
int size = 4000000;
  ......