数据结构


1     36    35    34    33    32    31    30    29    28    
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();
        }
    
    }
}



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值