1.完成数组int[]a={100,40,60,87,34,11,56,0}的快速排序、冒泡排序;快速排序实现代码:publicclassTest001{publicstaticvoidmain(String[]args){int[]a=newint[]{100,40,60,87,34,11,56,0};System.out.println(未排序之前的数据是:);print(a);System.out.println(排序之后的数据是:);sort(a,0,a.length-1);print(a);}//打印方法publicstaticvoidprint(int[]b){for(inti=0;ib.length;i++){System.out.print(b[i]+);}System.out.println();}//排序方法staticvoidsort(int[]a,intlow,inthigh){if(low=high)return;//low小于high,则直接返回if((high-low)==1){//如果只有两个数字,则直接比较if(a[0]a[1])swap(a,0,1);return;}intpivot=a[low];//取第一个数作为中间数intleft=low+1;intright=high;while(leftright){//从左边开始找while(leftright&&left=high){//如果左小于右则一直循环if(a[left]pivot)break;left++;//左下标往右边走一点}//从右边开始找while(left=right&&rightlow){//如果左大于右则一直循环if(a[right]=pivot)break;right--;//右下标往左走一点}if(leftright)//如果还没有找完,则交换数字swap(a,right,left);}swap(a,low,right);sort(a,low,right);sort(a,right+1,high);}//调位方法privatestaticvoidswap(int[]array,inti,intj){inttemp;temp=array[i];array[i]=array[j];array[j]=temp;}}打印结果为:未排序之前的数据是:1004060873411560排序之后的数据是:0113440566087100冒泡排序实现代码:publicclassTest002{publicstaticvoidmain(String[]args){int[]arr={100,40,60,87,34,11,56,0};//定义数组System.out.println(未排序之前的数据是:);maopaoPrint(arr);System.out.println();System.out.println(排序之后的数据是:);maopaoSort(arr);}//排序方法publicstaticvoidmaopaoSort(int[]arrys){//定义临时变量tempinttemp=0;//用j表示下标,遍历数组for(intj=0;jarrys.length;j++){//对于每一个数组元素,从0到还未排序的最大下标,总是把最大的数字放在后边for(intk=0;karrys.length-j-1;k++){if(arrys[k]arrys[k+1]){//判断当前数字与后面数字的大小temp=arrys[k];arrys[k]=arrys[k+1];arrys[k+1]=temp;}}}maopaoPrint(arrys);//打印输出}//打印方法publicstaticvoidmaopaoPrint(int[]l){for(inti=0;il.length;i++){System.out.print(l[i]+);//从小到大的输出}}}打印结果为:未排序之前的数据是:1004060873411560排序之后的数据是:01134405660871002.采用折半查找的算法,在数组中查询到某个数;实现代码:importjava.util.Scanner;publicclassTest003{publicstaticintMax=20;//数据数组源publicstaticintdata[]={12,16,19,22,25,32,39,39,48,55,57,58,63,68,69,70,78,84,88,90,97};//计数器publicstaticintcount=1;publicstaticvoidmain(String[]args){System.out.println(请输入您要查找的数字:);Scannersc=newScanner(System.in);intKeyValue=sc.nextInt();//调用折半查找if(Search(KeyValue)){//输出查找次数System.out.println(共查找了+count+次);}else{//输出没有找到数据System.out.println(抱歉,数据数组源中找不到您输入的数字);}}//折半查找法publicstaticbooleanSearch(intk){intleft=0;//左边界变量intright=Max-1;//右边界变量intmiddle;//中位数变量while(left=right){middle=(left+right)/2;if(kdata[middle]){right=middle-1;//查找前半段}elseif(kdata[middle]){left=middle+1;//查找后半段}elseif(k==data[middle]){System.out.println(Data[+middle+]=+data[middle]);returntrue;}count++;}returnfalse;}}3.输入一个字符串,其中包含数字、特殊符号(像:¥、&、(、等)、大小写字母等,然后输出每个字符串或符号的ASCII码的和;例如:输入“@#$%^&*():|”,则打印出643。实现代码:publicclassTest001{publicstaticvoidmain(String[]args){System.out.println(请输入一个字符串:);Scannersc=newScanner(System.in);Stringstr=sc.nextLine();intsum=0;for(inti=0;istr.length();i++){sum=sum+str.charAt(i);}System.out.println(您输入的字符串每个字节相加的和为:+sum);}}4.将一个数组中值=0的项去掉,将不为0的值存入一个新的数组比如:inta[]={0,1,3,4,5,0,0,6,6,0,5,4,7,6,7,0,5};生成的新数组为:intb[]={1,3,4,5,6,6,5,4,7,6,7,5}实现代码:importjava.util.*;publicclassTest001{publicstaticvoidmain(String[]args){inta[]={0,1,3,4,5,0,0,6,6,0,5,4,7,6,7,0,5};ListIntegerlist=newArrayListInteger();for(inti=0;ia.length;i++){if(a[i]!=0){list.add(a[i]);}}intb[]=newint[list.size()];for(inti=0;ilist.size();i++){b[i]=list.get(i);}System.out.println(原数组为:);for(inti=0;ia.length;i++){System.out.print(a[i]+);}System.out.println();System.out.println(去掉值为0的项之后为:);for(inti:b){System.out.print(i+);}}}5.定义10个长度的Student数组,将10个Student对象的年龄全部加1,然后把10个Student对象的详细信息逐行打印出来(数组和ArrayList实现)实现代码:第一个类:publicclassStudent{publicStringname;publicStringsex;publicintage;publicStringgetName(){returnname;}publicvoidsetName(Stringname){this.name=name;}publicStringgetSex(){returnsex;}publicvoidsetSex(Stringsex){this.sex=sex;}publicintgetAge(){returnage;}publicvoidsetAge(intage){this.age=age;}publicStudent(Stringname,Stringsex,intage){super();this.name=name;this.sex=sex;this.age=age;}}第二个类:importjava.util.ArrayList;importjava.util.List;publicclassTest001{staticStudent[]s=newStudent[10];intk=1;publicstaticvoidmain(String[]args){ListStudentli=newArrayListStudent();for(inti=0;i10;i++){li.add(newStudent(zhangsan+i,男,20));}for(inti=0;i10;i++){(li.get(i).age)++;}for(inti=0;i10;i++){System.out.println(li.get(i).getName()++li.get(i).getSex()++li.get(i).getAge());}}}6.有工人,农民,教师,科学家,服务生,其中,工人,农民,服务生只有基本工资.教师除基本工资外,还有课酬(元/天),科学家除基本工资外,还有年终奖,请你写出相关类,将各种类型的员工的全年工资打印出来实现代码:(共有7个类)第一个类:packagecom.softeem.zy006;/***定义一个人的接口,以供实现*/publicinterfacePeople{publicdoublenum();}第二个类:packagecom.softeem.zy006;/***工人类*/publicclassWorkerimplementsPeople{privatedoublemontherSalary;publicWorker(doublemontherSalary){super();this.montherSalary=montherSalary;}publicdoublenum(){returngetMontherSalary()*12;}publicdoublegetMontherSalary(){returnmontherSalary;}publicvoidsetMontherSalary(doublemontherSalary){this.montherSalary=montherSalary;}}第三个类:packagecom.softeem.zy006;/***农民类*/publicclassPeasantimplementsPeople{privatedoublemontherSalary;publicPeasant(doublemontherSalary){s