DC [26/05/2021]
IMPORTANT: Do not write the main() function as it is already defined.
Example Input/Output 1:
Input:
5 4
98 62 65 28
37 47 14 89
19 66 48 43
84 16 75 35
62 88 77 94
3
Output:
Column 3: 65 14 48 75 77
Explanation:
Here K = 3, the integers in the 3rd column are 65, 14, 48, 75 and 77.
Hence the output is
Column 3: 65 14 48 75 77
Function Get Column
Example Input/Output 2:
Input:
4 7
87 51 76 54 16 32 63
51 86 57 48 91 32 93
44 32 69 22 38 49 94
63 40 23 70 88 13 87
2
Output:
Column 2: 51 86 32 40
SOLUTION:
boundedArray* getColumn(int R, int C, int matrix[][C], int K)
{int output[1001],l=0;
for(int i=0;i<R;i++)
{
output[l++]=matrix[i][K-1]; //IN THIS LINE PUT CAPITAL K
}
boundedArray bArr,*ptr=&bArr;
bArr.SIZE=l;
bArr.arr=output;
return ptr;
}
Comments
Post a Comment