-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFlipHM.cpp
50 lines (41 loc) · 1.04 KB
/
FlipHM.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//
// main.cpp
// FlipHM
//
// Created by Jaime Hisao on 10/29/18.
// Copyright © 2018 Jaime Hisao. All rights reserved.
//
#include <iostream>
using namespace std;
int main(int argc, const char * argv[]) {
int line, column;
cin>>line>>column;
int mat1[line][column];
int arrTemp[column];
//Recieves Value of Array
for(int i = 0; i < line; i++){
for (int j = 0; j < column; j++) {
cin>>mat1[i][j];
}
}
//Sends Values to Temporary Array for storage, then sends back, but flipped
for(int i = 0; i < line; i++){
for (int j = 0; j < column; j++) {
arrTemp[j]=mat1[i][j];
}
//Returns Values
int counter = 0;
for (int k = column-1; k >=0; k--) {
mat1[i][counter] = arrTemp[k];
counter++;
}
}
//Prints Matrix
for(int i = 0; i < line; i++){
for (int j = 0; j < column; j++) {
cout<<mat1[i][j]<<" ";
}
cout<<endl;
}
return 0;
}