2 38 65 64 63 62 61 60 59 27
3 39 67 86 85 84 83 82 58 26
4 40 68 88 99 98 97 81 57 25
5 41 69 89 101 104 96 80 56 24
6 42 70 90 102 103 95 79 55 23
7 43 71 91 92 93 94 78 54 22
8 44 72 73 74 75 76 77 53 21
9 45 46 47 48 49 50 51 52 20
10 11 12 13 14 15 16 17 18 19
java程序打印出来
public class TestDS {
public static void main(String[] args) {
int cloumn =20 ,row = 10 ;
int startCloumn = 0 , endCloumn = 0, startRow = 0 , endRow = 0 ;
int count =row*cloumn;
int j = 0 ;
int arr[][] = new int[row][cloumn];
endCloumn = cloumn-1;
endRow = row -1;
for(int i = 1 ;i < count ;i++){
for(j =startRow;j<=endRow ;j++ ){
arr[j][startCloumn]= i;
i++;
}
startCloumn++;
for(j = startCloumn ; j<=endCloumn; j++){
arr[endRow][j] = i ;
i++;
}
endRow-- ;
for(j =endRow;j>=startRow ;j--){
arr[j][endCloumn]= i;
i++;
}
endCloumn--;
for(j = endCloumn ; j>=startCloumn; j--){
System.out.println(j+","+startRow);
arr[startRow][j] = i ;
i++;
}
startRow ++;
}
for(int i = 0 ;i <row ;i++){
for(j=0 ;j<cloumn ;j++){
System.out.print(arr[i][j]+" ");
if(arr[i][j]<10)
System.out.print(" ");
else if(arr[i][j]<100)
System.out.print(" ");
}
System.out.println();
}
}
}