排序的问题 在控制台任意输入一组数字进行排序小弟的JAVA基础不好,请各位指点~ 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我也是新手,前几天写的快速排序加以修改,楼主看满足你的要求不?import java.io.*;public class QuickSort { public static void sort(int[] a){ sort(a,0,a.length-1); } public static void sort(int[] a ,int i ,int j){ if(i < j){ int low = i ,high = j ,temp = a[i]; while(low != high){ while(low < high && a[high]>temp)high--; if(low < high)a[low++]=a[high]; while(low < high && a[low]<temp)low++; if(low < high)a[high--]=a[low]; } a[low]=temp; sort(a,i,low-1); sort(a,low+1,j); } } public static void print(int[] a){ for(int v:a){ System.out.print(v + " "); } } public static void inputNum() { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); try{ System.out.println("输入你要排序的数,中间用空格分开"); String s = br.readLine().trim(); String [] stringNums = s.split("\\s+"); int[] num = typeOf(stringNums); sort(num); print(num); }catch(NumberFormatException e1){ throw new RuntimeException("输入的类型不正确"); } catch(IOException e2){ e2.printStackTrace(); } } public static int[] typeOf(String[] s){ int[] number = new int[s.length]; int i = 0; for(String str:s){ number[i++] = Integer.parseInt(str); } return number; } public static void main(String[] args) { inputNum(); }} import java.io.*;public class pai{ public static void main(String args[]) throws Exception {BufferedReader put=new BufferedReader(new InputStreamReader(System.in));String input = put.readLine();int length=input.length();char sub[]=new char[length];input.getChars(0,length,sub,0);for(int i=0;i<length-1;i++){ if(sub[i]>sub[i+1]) { sub[i+1]=sub[i]; }}System.out.print(sub); }} 数组复制的问题 怎样获取一组不重复的随机数 一个if语法问题 Java当中有没有能够把字符窜里的数字转换成double的函数? TreeSet中的元素的排列问题? 菜鸟问题,请指教 想在java中运行.bat文件,可是没有执行 java中如何得到二个日期间的天数 Swing中的JTable这个问题请高手解答,谢谢!!……… 实际参数和形式参数长度不同? 关于在jar包中的js文件 一个JAVA题帮我看一下呀
import java.io.*;
public class QuickSort {
public static void sort(int[] a){
sort(a,0,a.length-1);
}
public static void sort(int[] a ,int i ,int j){
if(i < j){
int low = i ,high = j ,temp = a[i];
while(low != high){
while(low < high && a[high]>temp)high--;
if(low < high)a[low++]=a[high];
while(low < high && a[low]<temp)low++;
if(low < high)a[high--]=a[low];
}
a[low]=temp;
sort(a,i,low-1);
sort(a,low+1,j);
}
}
public static void print(int[] a){
for(int v:a){
System.out.print(v + " ");
}
}
public static void inputNum() {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
try{
System.out.println("输入你要排序的数,中间用空格分开");
String s = br.readLine().trim();
String [] stringNums = s.split("\\s+");
int[] num = typeOf(stringNums);
sort(num);
print(num);
}catch(NumberFormatException e1){
throw new RuntimeException("输入的类型不正确");
}
catch(IOException e2){
e2.printStackTrace();
}
}
public static int[] typeOf(String[] s){
int[] number = new int[s.length];
int i = 0;
for(String str:s){
number[i++] = Integer.parseInt(str);
}
return number;
}
public static void main(String[] args) {
inputNum();
}
}
public class pai
{
public static void main(String args[]) throws Exception
{BufferedReader put=new BufferedReader(new InputStreamReader(System.in));
String input = put.readLine();int length=input.length();
char sub[]=new char[length];
input.getChars(0,length,sub,0);
for(int i=0;i<length-1;i++)
{
if(sub[i]>sub[i+1])
{
sub[i+1]=sub[i];
}
}System.out.print(sub); }
}