在C编程中以蛇形模式打印矩阵

给定一个大小为nxn的数组,程序必须以蛇形模式打印数组的元素,而不对它们的原始位置进行任何更改

在C编程中以蛇形模式打印矩阵

示例

Input: arr[]= 100 99 98 97 93 94 95 96 92 91 90 89 85 86 87 88 Output: 100 99 98 97 96 95 94 93 92 91 90 89 88 87 86 85登录后复制

  • 如果行是偶数行,它将从左到右打印该行的元素

  • 如果行是奇数行,它将从右到左打印该行的元素

算法

START Step 1 -> create header files for declaring rows and column let’s say of size 4x4 Step 2 -> declare initial variables i and j and array[][] with elements Step 3 -> Loop For i=0 and i= 0; j--) printf("%d ",arr[i][j]); } } return 0; }登录后复制