-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patha_dynamic_list.cpp
More file actions
55 lines (49 loc) · 993 Bytes
/
a_dynamic_list.cpp
File metadata and controls
55 lines (49 loc) · 993 Bytes
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
#include<iostream>
using namespace std;
const int MAXSIZE=10;
int ar_len = 0;
int index =0;
void print_ar(int ar[]){
for(int i=0; i<ar_len; i++){
cout<<ar[i]<<" ";
}
cout<<endl;
}
int _remove(int ar[], int number){
for(int i=0; i<ar_len; i++){
if(ar[i]==number){
ar[i] = 0;
}
}
for(int i=0; i<ar_len; i++){
if(ar[i]==0){
index = i;
}
}
for(int i=index; i<ar_len; i++){
ar[i] = ar[i+1];
}
ar_len--;
print_ar(ar);
}
int _insert(int ar[], int number){
if(ar_len<MAXSIZE){
ar[ar_len++]=number;
cout<<'\n';
}
else{
cout<<"Buffer Overflow"<<endl;
}
}
int main(){
int A[MAXSIZE];
char input = 'N';
int input_number;
while(input != 'Y'){
cin>>input_number;
_insert(A,input_number);
cout<<"Again?"<<endl;
cin>>input;
}
_remove(A, 5);
}