-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGraded_Program4.cpp
More file actions
93 lines (70 loc) · 2.45 KB
/
Copy pathGraded_Program4.cpp
File metadata and controls
93 lines (70 loc) · 2.45 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#include <iostream>
#include<cstdlib>
using namespace std;
// Please write your code, within the "BEGIN-END" blocks given below.
// A "BEGIN-END" block is identified as follows :
//
// "//// BEGIN: Some string DONT_ERASE_xx_yy"
//
//
// "//// END: Some other string DONT_ERASE_xx_yy"
//
// where "xx" is the block number and "yy" is the
// marks allocated for the block
//
// The FIRST block (BLOCK 1 i.e. DONT_ERASE_01_0) carries 0 marks and
// is a placeholder for your personal information, to be written as a comment.
//
// WARNING :
// (1) Do NOT write any cout or cin statements
// (2) Do NOT delete or modify the existing code i.e. main function, comments, blocks, etc.
// (3) Write your code in between BEGIN and END of the respective blocks only
// (4) Do NOT rename the .cpp file
//// ---------------------------------------------------------------------------
//// BEGIN: Fill your details as comments below DONT_ERASE_01_0
//// Name: Neeraj Patidar
////
//// END: Fill your details as comments above DONT_ERASE_01_0
//// ---------------------------------------------------------------------------
//// ---------------------------------------------------------------------------
//// BEGIN: Write a function getArray1D DONT_ERASE_02_1
//// The function should return a 1D array to the function getArray2D from where it is called
int* getArray1D(int n, int *A)
{
A = (int*) malloc(n*sizeof(int));
return A;
}
//// END: End of function code DONT_ERASE_02_1
//// ---------------------------------------------------------------------------
//// ---------------------------------------------------------------------------
//// BEGIN: Write function getArray2D DONT_ERASE_03_1
//// The function should return a 2D array to the main function
//// Call the function getArray1D in this function
int** getArray2D(int m,int n,int **Array)
{
int *A;
Array = (int**)malloc(m*sizeof(int*));
for(int i=0;i<m;i++)
Array[i] = getArray1D(n,A);
return Array;
}
//// END: End of function code DONT_ERASE_03_1
//// ---------------------------------------------------------------------------
int main() {
int **Array;
int m, n;
cin>>m>>n;
Array = getArray2D(m,n,Array);
for(int i=0;i<m;i++)
for(int j=0;j<n;j++){
cin >> Array[i][j];
}
cout<<endl;
for(int i=0;i<m;i++){
for(int j=0;j<n;j++){
cout<<Array[i][j]<<" ";
}
cout<<endl;
}
return 0;
}