資源描述:
《信計(jì) java程序 期末復(fù)習(xí)》由會(huì)員上傳分享,免費(fèi)在線(xiàn)閱讀,更多相關(guān)內(nèi)容在教育資源-天天文庫(kù)。
1、1:設(shè)n為自然數(shù),則n!=1*2*3*…*n,稱(chēng)為n的階乘,并且規(guī)定0?。?。編寫(xiě)程序計(jì)算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:編寫(xiě)程序打印下面的圖案:???**********???*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)編寫(xiě)函數(shù)實(shí)現(xiàn)由大到小排序(2)編寫(xiě)函數(shù)實(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、個(gè)學(xué)生,并輸出學(xué)生信息。publicclass唔唔{publicstaticvoidmain(String[]args){Students1=newStudent("12","二班","開(kāi)開(kāi)",21,"女");s1.printInfo();Students2=newStudent("18","一班","關(guān)關(guān)",22,"女");s2.printInfo();}}classStudent{privateStringsno;privateStringcno;privateStringname;privateintage;privateStringsex;publicS
8、tudent(Strin