简单算法


package Sort;

import java.io.IOException;

public class Main {
static int temp;
public static void main(String args[]) throws IOException {
int[] a = {5, 23, 45, 7, 3, 65, 76, 4, 5, 45};

insertSort(a);

try {
for(int i=0;i<10;i++) {
System.out.print(a[i]+" ");
}
}
catch (Exception e) {
System.out.print("inpiut error");
}
}
public static void Sort(int a[]) {
int i,j;
for(i=0;i<a.length;i++){
for(j=i+1;j<a.length;j++){
temp = a[i];
if(temp>a[j]) {
a[i] = a[j];
a[j]=temp;
}
}
}
}
}
posted @ 2018-04-21 09:16  怡城  阅读(113)  评论(0编辑  收藏  举报