- 博客(14)
- 收藏
- 关注
原创 汉诺塔算法
public class HanoTower { public static void doTower(int topN,char from,char inter,char to) { if (topN==1) { //当只有一个盘子时,直接放入to底座 System.out.println("盘子1从"+from+"塔座到"+to+"塔座"); } else { //当大于一个盘
2017-03-11 17:11:59
223
原创 堆排序算法
public class heapsort { //构成堆 public static int[] heap(int[] a,int n) { int t; //从最后一个非叶结点开始按照从大到小进行堆构建 for (int i = n/2; i > 0; i--) { if (i*2+1>n) { //如果最后一个非叶结点只有左子树 if (a[i-1] //如果子树数
2017-03-11 16:58:07
218
原创 底面接口形状的柱体
public class Fjava { public static void main(String[] args) { Geometry a=new Circle(2); Geometry b=new Rect(2,3); Pillar v1=new Pillar(3,a); Pillar v2=new Pillar(2,b); v1.Volume(); v2.Vo
2016-04-10 15:33:00
644
原创 学生接口人
public class Fjava { public static void main(String[] args) { Person a=new Student(); a.SetData("张三","男","1995/12/25","12","睡觉"); a.GetData(); } } public interface Person { vo
2016-04-10 15:22:07
362
原创 形状的周长与面积
public class Fjava { public static void main(String[] args) { Shape[] Shape=new Shape[2]; Shape[0]=new Rect(3,4); Shape[1]=new Circle(2); for(int i=0;i { Shape[i].ZhouC(); Shape[i].Mian
2016-04-10 13:42:40
320
原创 五个学生
public class Fjava { public static void main(String[] args) { Student a=new Student(1,"张三","男",19,90); Student b=new Student(2,"张四","女",18,85); Student c=new Student(3,"张五","男",19,92); Stu
2016-03-31 23:52:03
291
原创 无名的粉
public class Fjava { public static void main(String[] args) { WuMingFen f1 = new WuMingFen("牛肉",3,true); WuMingFen f2 = new WuMingFen("牛肉",2); WuMingFen f3 = new WuMingFen(); f1.check();
2016-03-31 22:52:03
2712
原创 数组中插数
public class Fjava { public static void main(String[] args) { int[] a=new int[10]; for (int i=0;i { a[i]=i*2; //System.out.println(a[i]); } int n=5; for (int j=0;j { if (a[j]>n) {
2016-03-31 00:41:28
265
原创 圆柱的面积,体积,半径
public class Fjava { public static void main(String[] args) { Cylinder c=new Cylinder(2,3); c.show(); c.showVolume(); } } public class Circle { private double Radius; public Circ
2016-03-30 23:47:11
377
原创 三个数从大到小排列
import java.util.*; public class Fjava { public static void main(String[] args) { int x,y,z; Scanner s=new Scanner(System.in); x=s.nextInt(); y=s.nextInt(); z=s.nextInt(); if(x>y)
2016-03-28 20:48:31
361
原创 最大公约数和最小公倍数
import java.util.*; public class Fjava { public static void main(String[] args) { int m,n,x,y,a,b; Scanner s=new Scanner(System.in); x=m=s.nextInt(); y=n=s.nextInt(); if (m do {
2016-03-28 20:31:15
217
原创 101~200素数
public class Fjava { public static void main(String[] args) { int n=0; for(int i=101;i { for(int j=2;j { if(i%j==0) break; else { n++; System.out.printf(i+" "); break; } } }
2016-03-28 18:54:40
189
原创 金字塔
public class Fjava { public static void main(String[] args) { int n=4; for(int i=1;i { for(int j=n-i;j>0;j--) System.out.printf(" "); for(int k=1;k System.out.printf("*"); System.o
2016-03-28 18:12:46
278
原创 九九乘法表
public class Fjava { public static void main(String[] args) { for (int i=0;i { int k=i+1; for(int j=1;j { System.out.println(k+"*"+j+"="+(k*j)); if(j==k) continue; System.out.print
2016-03-28 13:22:55
178
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人