-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
remove a alphabet from 2D dynamic array in class.cpp
86 lines (86 loc) · 1.29 KB
/
remove a alphabet from 2D dynamic array in class.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
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
#include<iostream>
#include<cstring>
using namespace std;
class A
{
private:
int r, c;
char** arr;
public:
A()
{
r = 0;
c = 0;
arr = nullptr;
}
void Setter(int r,int c)
{
this->r = r;
this->c = c;
arr = new char* [r];
for (int i = 0; i < r; i++)
{
arr[i] = new char[c];
}
}
void Input(int row, int col)
{
for (int i = 0; i < row; i++)
{
for (int j = 0; j < col; j++)
{
cin >> arr[i][j];
}
}
}
void Output()
{
for (int i = 0; i < r; i++)
{
for (int j = 0; j < c; j++)
{
cout << arr[i][j]<<" ";
}
cout << endl;
}
}
void Check(int check)
{
for (int i = 0; i < r; i++)
{
for (int j = 0; j < c; j++)
{
if (arr[i][j]==check)
{
arr[i][j] = '-';
}
else
{
arr[i][j];
}
}
}
}
};
int main()
{
int row, col;
char see;
cout << "Number of Rows : ";
cin >> row;
cout << "Number of Columns : ";
cin >> col;
A array;
array.Setter(row, col);
cout << "Input : " << endl;
array.Input(row, col);
cout << "Display array : " << endl;
array.Output();
cout << endl;
cout << "Alphabet to be removed : ";
cin >> see;
array.Check(see);
cout << "Array after Removing Alphabet : " << endl;
array.Output();
return 0;
}