資源描述:
《信計 java程序 期末復習》由會員上傳分享,免費在線閱讀,更多相關(guān)內(nèi)容在教育資源-天天文庫。
1、1:設n為自然數(shù),則n!=1*2*3*…*n,稱為n的階乘,并且規(guī)定0!=1。編寫程序計算2!,4!,6!,8!和10!,并將結(jié)果輸出到屏幕上。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:已知數(shù)組a,包括的元素為{10,78,12,15,46,47,2,10}(1)編寫函數(shù)實現(xiàn)由大到小排序(2)編寫函數(shù)實現(xiàn)元素查找(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","一班","關(guān)關(guān)",22,"女");s2.printInfo();}}classStudent{privateStringsno;privateStringcno;privateStringname;privateintage;privateStringsex;publicS
8、tudent(Strin