共有回帖数  0  个 
	 
	
	
	
     
          
          
               
				
			 
				
					 
 
            
				   - 
						
						
							 
									运行结果: 
please input a number between 1 to 99 
10 
1   2   3   4   5   6   7   8   9   10 
36  37  38  39  40  41  42  43  44  11 
35  64  65  66  67  68  69  70  45  12 
34  63  84  85  86  87  88  71  46  13 
33  62  83  96  97  98  89  72  47  14 
32  61  82  95  100 99  90  73  48  15 
31  60  81  94  93  92  91  74  49  16 
30  59  80  79  78  77  76  75  50  17 
29  58  57  56  55  54  53  52  51  18 
28  27  26  25  24  23  22  21  20  19 
Press any key to continue 
程序清单 
#include stdio.h 
int n; 
int count=1; 
int a[100][100]={0}; 
void eva(int x) 
{ 
        register        int     i=x; 
        register        int     j=x; 
        if(2*xn) 
                a[j]=count++; 
        else 
        { 
                for(;j=n-x;j++) 
                        a[j]=count++; 
                for(;i=n-x;i++) 
                        a[j]=count++; 
                for(;jx;j--) 
                        a[j]=count++; 
                for(;ix;i--) 
                        a[j]=count++; 
        } 
} 
int main(void) 
{ 
        int        y=1; 
        register        int     i; 
        register        int     j; 
        printf("please input a number between 1 to 99n"); 
        while(scanf("%d",&n),n99 || n1); 
        while(y=n/2+n%2) 
                eva(y++); 
        for(i=1;i=n;i++) 
        { 
                for(j=1;j=n;j++) 
                        printf("%-4d",a[j]); 
                putchar('n'); 
        } 
        return 0; 
}
#define N 7 
int main(int argc, char* argv[]) 
{ 
int num[N][N],a,x=0,y=0,n=1; 
for(a=N-1;a0;a-=2) 
{ 
int b; 
for(b=x;x-ba;x++,n++) 
num[x][y]=n; 
for(b=y;y-ba;y++,n++) 
num[x][y]=n; 
for(b=x;b-xa;x--,n++) 
num[x][y]=n; 
for(b=y;b-ya;y--,n++) 
num[x][y]=n; 
num[++x][++y]=n; 
} 
for(x=0;xN;x++) 
{ 
for(y=0;yN;y++) 
printf("%d	",num[x][y]); 
printf("nnn"); 
} 
return 0; 
}
							 
							 
							 
							  
							  
							  楼主 2016-02-04 14:23 回复
						 
						 
           
          
          
         
   
         
      
 
   
             
                  
                  
 
 
 
     
	 
  
	Copyright © 2010~2015 直线网 版权所有,All Rights Reserved.沪ICP备10039589号
	
	意见反馈 | 
	关于直线 | 
	版权声明 | 
	会员须知