Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #define rows 5
- #define cols 5
- #define size 9
- void shift(char arr[rows][cols]){
- for(int i= cols-1;i>0;i--){
- for(int j=0;j<cols;j++){
- arr[i][j] = arr[i-1][j];
- }
- }
- for(int i=0;i<=rows-1;i++){
- arr[0][i] =0;
- }
- puts("");
- for(int i=0;i<rows;i++){
- for(int j=0;j<cols;j++){
- printf("%d ", arr[i][j]);
- }
- puts("");
- }
- }
- int main(){
- char arr[rows][cols]={
- {1,1,1,1,1},
- {2,2,2,2,2},
- {3,3,3,3,3},
- {4,4,4,4,4},
- {5,5,5,5,5}
- };
- puts("PreShift");
- for(int i=0;i<rows;i++){
- for(int j=0;j<cols;j++){
- printf("%d ", arr[i][j]);
- }
- puts("");
- }
- shift(arr);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement