package practice;
import ;
public class Paixu{
static void sort2(int n,int m){
("随机产生的"+n+"行"+m+"列数组:");
int [][] a = new int[n][m];
for (int i = 0;i < ; i++) {
for (int j = 0;j < a[i].length; j++) {
a[i][j] = (int)(()*110)-10;
}
}
for (int i = 0;i < ; i++) {
for (int j = 0;j < a[i].length; j++) {
(a[i][j]);
("\t");
}
();
}
for (int k = 0;k < n*m; k++) {
for (int i = 0;i < n; i++) {
for (int j = 0;j < m; j++) {
if ((j+1)%a[i].length != 0) {
if (a[i][j] > a[i][j+1]) {
int temp = a[i][j];
a[i][j] = a[i][j+1];
a[i][j+1] = temp;
}
} else {
if (i+1 != ) {
if (a[i][j] > a[i+1][(j+1)%a[i].length]) {
int temp = a[i][j];
a[i][j] = a[i+1][(j+1)%a[i].length];
a[i+1][(j+1)%a[i].length] = temp;
}
}
}
}
}
}
("排序后");
for (int i = 0;i < ; i++) {
for (int j = 0;j < a[i].length; j++) {
(a[i][j]);
("\t");
}
();
}
}
public static void main(String[] args) {
("please input n and m:");
Scanner scan = new Scanner();
try{
int a=();
int b=();
sort2(a,b);
}catch(Exception e){
("捕获到异常,异常信息是"+());
}
}
}