热门面试题与答案和在线测试
面向面试准备、在线测试、教程与实战练习的学习平台

通过聚焦学习路径、模拟测试和面试实战内容持续提升技能。

WithoutBook 将分主题面试题、在线练习测试、教程和对比指南整合到一个响应式学习空间中。

面试准备

模拟考试

设为首页

收藏此页面

订阅邮箱地址

Without Book 提问

问题. Please give me a sorting programming example source code on java.

- Please give me a sorting programming example source code on java.

发布时间 Sep 28, 2010 发布者 Shekhar
回答.
import java.io.*;
class sort
{
public static void main(String ar[])throws IOException
{
DataInputStream n=new DataInputStream(System.in);
int temp,i,no,a[]=new int[20];
System.out.println("enter the no. of elements to be sorted not greater than 20");
String lim=n.readLine();
no=Integer.parseInt(lim);
System.out.println("enter the ("+no+") numbers: ");
for(i=0;i {
String q=n.readLine();
a[i]=Integer.parseInt(q);
}

for(i=0;i {
for(int j=i+1;j {
if(a[i]>a[j])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
}
System.out.println("the list after sorting is: ");
for(i=0;i System.out.println(" "+a[i]);
}
}
发布时间 Sep 28, 2010 发布者 Arindam Ghosh

输入你的回答

姓名
邮箱地址
回答
安全验证
继续前请计算: 6 + 8 = ?
版权所有 © 2026,WithoutBook。