forked from rakeshcusat/Code4Reference
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added new folder called Algorithm. This folder will have various algo…
…rithm related programs
- Loading branch information
1 parent
7601735
commit bb83242
Showing
2 changed files
with
33 additions
and
2 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#include <stdio.h> | ||
|
||
#define MAX_SIZE 4 | ||
|
||
void zigzagArray(int array[][MAX_SIZE], int size){ | ||
|
||
int rows=0; | ||
int columns=0; | ||
|
||
while(rows<size){ | ||
printf("%d ",array[rows][columns]); | ||
|
||
if(rows==size-1){ | ||
rows = columns + 1; | ||
columns = size - 1; | ||
}else if(columns ==0){ | ||
columns = rows + 1; | ||
rows = 0; | ||
}else{ | ||
rows++; | ||
columns--; | ||
} | ||
}//end of while | ||
} | ||
|
||
int main(int arc, char **argv){ | ||
|
||
int myarray[MAX_SIZE][MAX_SIZE]={{1,2,3,4},{5,6,7,8},{9,10,11,12},{13,14,15,16}}; | ||
|
||
zigzagArray(myarray,MAX_SIZE); | ||
return 0; | ||
} | ||
|
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