欢迎来到天天文库
浏览记录
ID:40557331
大小:115.00 KB
页数:17页
时间:2019-08-04
《java期末编程题》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、实验(一)流程控制l输入源代码packagecom.fafu.data;importjava.util.Scanner;publicclassDataTransfer{/***@paramargs*/publicstaticStringtransfer2Other(intnum,intbase){Stringstr="";while(num!=0){str+=((num%base>=10)?(char)('A'+(num%10)):num%base);num/=base;}returnstr;}publicstatic
2、StringtoBinary(intnum){returnDataTransfer.transfer2Other(num,2);}publicstaticStringtoOctal(intnum){returnDataTransfer.transfer2Other(num,8);}publicstaticStringtoHexadecimal(intnum){returnDataTransfer.transfer2Other(num,16);}publicstaticStringReverse(Strings){Str
3、ingstr="";for(inti=s.length()-1;i>=0;--i){str+=(s.charAt(i));}returnstr;}publicstaticvoidmain(String[]args){//TODOAuto-generatedmethodstubScannerinput=newScanner(System.in);System.out.print("Enteranumber:");intn=input.nextInt();System.out.print("Enterabase:");in
4、tbase=input.nextInt();System.out.println(n+"transferedby"+base+"is"+Reverse(DataTransfer.transfer2Other(n,base)));System.out.println(n+"transferedby2is"+Reverse(DataTransfer.transfer2Other(n,2)));System.out.println(n+"transferedby8is"+Reverse(DataTransfer.transf
5、er2Other(n,8)));System.out.println(n+"transferedby16is"+Reverse(DataTransfer.transfer2Other(n,16)));}}实验(二)数组packagecom.fafu.experiment;importjava.util.Scanner;/***@authorAdministrator**/publicclassMatrixTest{/***@paramargs*//***一维矩阵最大值*@parammatrix*@return*/pub
6、licstaticintmax(intmatrix[]){inttmp=matrix[0];for(inti=1;i7、col8、ammatrix*@return*/publicstaticdoubleaverage(intmatrix[][]){doublesum=0.0;intmax_col=matrix[0].length;for(introw=0;row
7、col8、ammatrix*@return*/publicstaticdoubleaverage(intmatrix[][]){doublesum=0.0;intmax_col=matrix[0].length;for(introw=0;row
8、ammatrix*@return*/publicstaticdoubleaverage(intmatrix[][]){doublesum=0.0;intmax_col=matrix[0].length;for(introw=0;row
此文档下载收益归作者所有