Created
September 21, 2011 02:50
-
-
Save vigneshsarma/1231095 to your computer and use it in GitHub Desktop.
My first solution with out the base case
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
#include<conio.h> | |
//int w[20][20]; | |
int w[3][3]={1,2,3,4,5,6,7,8,9}; | |
int N=3; | |
void printer(int n) { | |
int i,j; | |
printf("\n "); | |
for ( i=N-n;i<n;i++) { | |
printf(" %d",w[N-n][i]); | |
} | |
for ( j=N-n+1;j<n;j++) { | |
printf("\n"); | |
for ( i=N-n;i<n;i++) { | |
printf(" "); | |
} | |
printf("%d",w[j][n-1]); | |
} | |
for ( j=N-n+1;j<n;j++) { | |
printf("\n %d",w[j][N-n]); | |
} | |
for ( i=N-n+1;i<n-1;i++) { | |
printf(" %d",w[n-1][i]); | |
} | |
//printer(n-1); | |
} | |
int main() | |
{ | |
int i,j; | |
/* | |
printf("enter n:"); | |
scanf("%d",&N); | |
for ( i=0;i<N;i++) { | |
for ( j=0;j<N;j++) { | |
scanf("%d",&w[i][j]); | |
} | |
}*/ | |
for ( i=0;i<N;i++) { | |
printf("\n"); | |
for ( j=0;j<N;j++) { | |
printf(" %d",w[i][j]); | |
} | |
} | |
printer(N); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Spiraling through a matrix half answer.