欢迎来到天天文库
浏览记录
ID:38789981
大小:45.44 KB
页数:17页
时间:2019-06-19
《信计 java程序 期末复习》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、1:设n为自然数,则n!=1*2*3*…*n,称为n的阶乘,并且规定0!=1。编写程序计算2!,4!,6!,8!和10!,并将结果输出到屏幕上。publicclasshaha{publicstaticvoidmain(String[]args){System.out.println(getN(2));System.out.println(getN(4));System.out.println(getN(6));System.out.println(getN(8));System.out.println(getN(10));}publicstaticintgetN
2、(intn){if(n==0)return1;elsereturn(n*getN(n-1));}}2:编写程序打印下面的图案: ********** *publicclasss1{publicvoidprintAstar(){System.out.print("*");}publicstaticvoidmain(String[]args){intinitLine=10;intinitNum=10;s1pt=news1();for(inti=0;i3、star();}System.out.println();}}}3:已知数组a,包括的元素为{10,78,12,15,46,47,2,10}(1)编写函数实现由大到小排序(2)编写函数实现元素查找(1)publicclasshh{publicstaticvoidmain(String[]args){int[]a={10,78,12,15,46,47,2,10};inttemp;for(intj=0;ja[i]){temp=a[j];a[j]=a[i];a[i]4、=temp;}}}System.out.print("从大到小的排列为:");for(inti=0;i5、6、gth;booleanflag=true;for(inti=0;i7、个学生,并输出学生信息。publicclass唔唔{publicstaticvoidmain(String[]args){Students1=newStudent("12","二班","开开",21,"女");s1.printInfo();Students2=newStudent("18","一班","关关",22,"女");s2.printInfo();}}classStudent{privateStringsno;privateStringcno;privateStringname;privateintage;privateStringsex;publicS8、tudent(Strin
3、star();}System.out.println();}}}3:已知数组a,包括的元素为{10,78,12,15,46,47,2,10}(1)编写函数实现由大到小排序(2)编写函数实现元素查找(1)publicclasshh{publicstaticvoidmain(String[]args){int[]a={10,78,12,15,46,47,2,10};inttemp;for(intj=0;ja[i]){temp=a[j];a[j]=a[i];a[i]
4、=temp;}}}System.out.print("从大到小的排列为:");for(inti=0;i5、6、gth;booleanflag=true;for(inti=0;i7、个学生,并输出学生信息。publicclass唔唔{publicstaticvoidmain(String[]args){Students1=newStudent("12","二班","开开",21,"女");s1.printInfo();Students2=newStudent("18","一班","关关",22,"女");s2.printInfo();}}classStudent{privateStringsno;privateStringcno;privateStringname;privateintage;privateStringsex;publicS8、tudent(Strin
5、6、gth;booleanflag=true;for(inti=0;i7、个学生,并输出学生信息。publicclass唔唔{publicstaticvoidmain(String[]args){Students1=newStudent("12","二班","开开",21,"女");s1.printInfo();Students2=newStudent("18","一班","关关",22,"女");s2.printInfo();}}classStudent{privateStringsno;privateStringcno;privateStringname;privateintage;privateStringsex;publicS8、tudent(Strin
6、gth;booleanflag=true;for(inti=0;i7、个学生,并输出学生信息。publicclass唔唔{publicstaticvoidmain(String[]args){Students1=newStudent("12","二班","开开",21,"女");s1.printInfo();Students2=newStudent("18","一班","关关",22,"女");s2.printInfo();}}classStudent{privateStringsno;privateStringcno;privateStringname;privateintage;privateStringsex;publicS8、tudent(Strin
7、个学生,并输出学生信息。publicclass唔唔{publicstaticvoidmain(String[]args){Students1=newStudent("12","二班","开开",21,"女");s1.printInfo();Students2=newStudent("18","一班","关关",22,"女");s2.printInfo();}}classStudent{privateStringsno;privateStringcno;privateStringname;privateintage;privateStringsex;publicS
8、tudent(Strin
此文档下载收益归作者所有