Question

In: Computer Science

Garden Lili inherited her grandfather’s land and wanted to start gardening. Lili’s garden size is X...

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){

Solutions

Expert Solution

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:


Related Solutions

The National Association for Gardening says that the average vegetable garden size has a standard deviation...
The National Association for Gardening says that the average vegetable garden size has a standard deviation of 247 sq ft. A random sample of 210 households shows an average size of 642 sq ft. Find a 90% confidence interval for the average size vegetable garden.
Mrs Solly signed as a surety for her nephew that wanted to start a panel beating...
Mrs Solly signed as a surety for her nephew that wanted to start a panel beating company. Mrs Solly’s nephew has being lying about his business doing poorly and continuously borrows money from Mrs Solly. Due to this lie, Mrs Solly does not want to fulfil her obligations in terms of the Suretyship Agreement. Legally advise Mrs Solly on the following: 1.1 The nature of a Surety Agreement 1.2 The benefits available to a Surety 1.3 The various ways in...
When Arlene Ryan inherited $250,000 from her grandfather, she decided to use the money to start...
When Arlene Ryan inherited $250,000 from her grandfather, she decided to use the money to start her own business. Arlene has been a legal secretary for 14 years and feels she knows quite a lot about business. “Every day I take depositions and type legal memoranda,” she noted to a friend. “And I’ve seen lots of businesses fail because they didn’t have adequate capital or proper management. Believe me, when you work for a law firm, you see—and learn—plenty. Almost...
A lecturer wanted to analyze the relationship between land area (X, square metre) in the locality...
A lecturer wanted to analyze the relationship between land area (X, square metre) in the locality of a certain district in one of the state in Malaysia and the land price (Y, RM million), by using nine plots selected randomly. The following statistics were obtained. ∑ ? = 5233; ∑ ? 2 = 3120639;∑ ? = 14.9; ∑ ? 2 = 28.89; ∑ ?? = 9217.8 a) Find the equation of the least squares regression line relating the land area...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT