📄 testoverload.java
字号:
class SortInt_1 {
int i,j,k,temp;
void SortInt(int a1,int a2[]) { //升序排序
for(i=0;i<a1-1;i++) {
k=i;
for(j=i+1;j<a1;j++)
if(a2[j]<a2[k]) k=j;
if(k!=i) {
temp=a2[i]; a2[i]=a2[k]; a2[k]=temp;
}
}
}
}
class SortInt_2 extends SortInt_1 {
int i,j,k,temp;
void SortInt(int a1,int a2[]) { //降序排序
for(i=0;i<a1-1;i++) {
k=i;
for(j=i+1;j<a1;j++)
if(a2[j]>a2[k]) k=j;
if(k!=i) {
temp=a2[i]; a2[i]=a2[k]; a2[k]=temp;
}
}
}
}
class TestOverload {
public static void main(String[] args)
{
int a[]={10,55,100,35,87,90,100,16};
SortInt_1 NewInt1=new SortInt_1(); //创建SortInt_1类的对象
NewInt1.SortInt(a.length,a); //调用SortInt_1类的方法
System.out.println("升序排列的数据:");
for(int i=0;i<8;i++)
System.out.print(a[i]+" ");
System.out.println(); //产生一行空行
SortInt_2 NewInt2=new SortInt_2(); //创建SortInt_2类的对象
NewInt2.SortInt(a.length,a); //调用SortInt_1类的方法
System.out.println("降序排列的数据:");
for(int i=0;i<8;i++)
System.out.print(a[i]+" ");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -