Advertisement
valve2

arr[0][] = 0+1 && [0][0]=0

Jun 2nd, 2023
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.67 KB | Software | 0 0
  1. #include <stdio.h>
  2. #define rows 5
  3. #define cols 5
  4. #define size 9
  5. void shift(char arr[rows][cols]){
  6.  
  7. for(int i= cols-1;i>0;i--){
  8.     for(int j=0;j<cols;j++){
  9.     arr[i][j] = arr[i-1][j];
  10.     }
  11. }
  12. for(int i=0;i<=rows-1;i++){
  13.     arr[0][i] =0;
  14. }
  15.  
  16.  
  17.  
  18. puts("");
  19. for(int i=0;i<rows;i++){
  20.     for(int j=0;j<cols;j++){
  21.     printf("%d  ", arr[i][j]);
  22.     }
  23.     puts("");
  24. }
  25.  
  26.  
  27.  
  28. }
  29. int main(){
  30. char arr[rows][cols]={
  31.     {1,1,1,1,1},
  32.     {2,2,2,2,2},
  33.     {3,3,3,3,3},
  34.     {4,4,4,4,4},
  35.     {5,5,5,5,5}
  36.     };
  37. puts("PreShift");
  38. for(int i=0;i<rows;i++){
  39.     for(int j=0;j<cols;j++){
  40.     printf("%d  ", arr[i][j]);
  41.     }
  42.     puts("");
  43. }
  44. shift(arr);
  45. return 0;
  46. }
  47.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement