-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathChenHang.cpp
43 lines (39 loc) · 930 Bytes
/
ChenHang.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
#include <iostream>
using namespace std;
void inputArray(int arr[][100], int m, int n)
{
for (int i = 0; i < m; i++)
for (int j = 0; j < n; j++)
cin >> arr[i][j];
}
void outputArray(int arr[][100], int m, int n)
{
for (int i = 0; i < m; i++)
{
for (int j = 0; j < n; j++)
cout << arr[i][j] << " ";
cout << endl;
}
}
void replaceArray(int arr[][100], int m, int n, int x, int y)
{
for (int i = m; i >= x; i--)
{
for (int j = 0; j < n; j++)
arr[i][j] = arr[i - 1][j]; // replace value down 1
}
for (int i = 0; i < n; i++)
arr[x - 1][i] = y; // write value to array
}
int main()
{
int m, n;
int x, y;
int arr[100][100];
cin >> m >> n;
inputArray(arr, m, n);
cin >> x >> y;
replaceArray(arr, m, n, x, y);
outputArray(arr, m + 1, n);
return 0;
}