#include <stdio.h>
void matrix (int m, int n, int t)
{
int arr[m][n];
int i, j, k;
for (i = 0; i < m; i++){
for (j = 0; j < n; j++){
scanf("%d", &arr[i][j]);
}
}
if (t == 0){//左右翻转
for (i = 0; i < m; i++){
for (j = n-1; j >= 0; j--){
if ( j == 0 ) {
printf("%d", arr[i][j]);
}
else {
printf("%d ", arr[i][j]);
}
}
printf("\n");
}
}
else if (t == 1){//上下翻转
for (i = m-1; i >= 0; i--){
for (j = 0; j < n; j++){
if ( j == n - 1 ) {
printf("%d", arr[i][j]);
}
【C】矩阵翻转(上下翻转、左右翻转)
最新推荐文章于 2024-02-24 17:46:29 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)