In: Computer Science
Garden
Lili inherited her grandfather’s land and wanted to start gardening. Lili’s garden size is X × Y with various types of plants marked with integer c.
Given a two-dimensional array that contains the type of plant in the garden. Lily wants to make T changes to the garden. For each change made, Lili will plant c in the a-th row of the b-th column of the array. The row and column starts from number 1.
Format Input:
The input consists of integers X and Y followed by an array of X × Y , then contains an integer T which is the number of changes made by Lili. The next T line contains three numbers a, b, c which contains the array location index you want to change to the integer c.
Format Output:
The output contains a two dimensional array in the form of a Lili garden plan after a change is made.
Constraints
• 1 ≤ a, b, c, X, Y ≤ 100
• 1 ≤ T ≤ 1000
Sample Input 1 (standard input):
3 3
1 1 1
1 1 1
1 1 1
3
1 1 3
2 2 3
3 3 3
Sample Output 1 (standard output):
3 1 1
1 3 1
1 1 3
Sample Input 2 (standard input):
5 3
1 2 3
4 5 6
7 8 9
10 11 12
13 14 15
3
1 1 16
1 2 17
1 3 18
Sample Output 2 (standard output):
16 17 18
4 5 6
7 8 9
10 11 12
13 14 15
note : USE C language, integer must be the same as the constraint, DONT USE VOID, RECURSIVE(RETURN FUNCTION), RESULT, code it under int main (must be blank){
main.c
#include <stdio.h>
int main()
{
int X,Y;
scanf("%d %d",&X, &Y);
int array[X][Y];
for(int i=0; i<X; i++){
for(int j=0; j<Y; j++){
scanf("%d",&array[i][j]);
}
}
int T;
scanf("%d",&T);
int change[T][3];
for(int i=0; i<T; i++){
for(int j=0; j<3; j++){
scanf("%d",&change[i][j]);
}
}
for(int i=0; i<T; i++){
array[change[i][0]-1][change[i][1]-1]=change[i][2];
}
printf("\n");
for(int i=0; i<X; i++){
for(int j=0; j<Y; j++){
printf("%d ",array[i][j]);
}
printf("\n");
}
return 0;
}
Code Snippet (For Indentation):
Output: