自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

  • 博客(0)
  • 资源 (3)
  • 问答 (1)
  • 收藏
  • 关注

空空如也

40个java算法题,都弄会了,java基础就算入门了,很经典

【程序1】 题目:判断101-200之间有多少个素数,并输出所有素数。 1.程序分析:判断素数的方法:用一个数分别去除2到sqrt(这个数),如果能被整除, 则表明此数不是素数,反之是素数。 public class exp2{ public static void main(String args[]){ int i=0; math mymath = new math(); for(i=2;i<=200;i++) if(mymath.iszhishu(i)==true) System.out.println(i); } } class math { public int f(int x) { if(x==1 || x==2) return 1; else return f(x-1)+f(x-2); } public boolean iszhishu(int x) { for(int i=2;i<=x/2;i++) if (x % 2==0 ) return false; return true; } } 【程序2】 题目:打印出所有的 "水仙花数 ",所谓 "水仙花数 "是指一个三位数,其各位数字立方和等于该数本身。例如:153是一个 "水仙花数 ",因为153=1的三次方+5的三次方+3的三次方。 1.程序分析:利用for循环控制100-999个数,每个数分解出个位,十位,百位。 public class exp2{ public static void main(String args[]){ int i=0; math mymath = new math(); for(i=100;i<=999;i++) if(mymath.shuixianhua(i)==true) System.out.println(i); } } class math { public int f(int x) { if(x==1 || x==2) return 1; else return f(x-1)+f(x-2); } public boolean iszhishu(int x) { for(int i=2;i<=x/2;i++) if (x % 2==0 ) return false; return true; } public boolean shuixianhua(int x) { int i=0,j=0,k=0; i=x / 100; j=(x % 100) /10; k=x % 10; if(x==i*i*i+j*j*j+k*k*k) return true; else return false; } }

2012-06-13

eclipse viplugin插件 免费

eclipse viplugin插件 免费,不会vi的人学习vi,习惯vi 的人喜欢eclipse

2011-07-13

linux vi命令集合

介绍了linux vi的一些命令,使你更方便的学习vi,熟悉linux

2011-07-13

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除