fork download
  1. #include <iostream>
  2. using namespace std;
  3. class Arr {
  4. private:
  5. int size;
  6. int maxSize;
  7. int *arr;
  8.  
  9. public:
  10. Arr(int x){
  11. maxSize = x;
  12. size = 0;
  13. arr = new int[maxSize];
  14. }
  15.  
  16. void insertelement(int x){
  17. for (int i = 0; i < x; i++) {
  18. cout << "Enter Value of Index: "<<i<<endl;
  19. cin >> arr[i];
  20. size++;
  21. }
  22. }
  23.  
  24. void display(){
  25. cout<<"the content: "<<endl;
  26. for (int i = 0; i < size; i++) {
  27. cout << "Index " << i << ": ";
  28. cout << arr[i] << endl;
  29. }
  30. }
  31.  
  32. void Searsh(int Var){
  33. bool found = false;
  34. for (int i = 0; i < size; i++) {
  35. if (arr[i] == Var) {
  36. cout << "Element " << Var << " found at index : " << i << endl;
  37. found = true;
  38. break;
  39. }
  40. }
  41. if (found==false) {
  42. cout << "This Value Not Found ! " << endl;
  43. }
  44. }
  45.  
  46. bool Full(){
  47. if (maxSize == size) {
  48. return true;
  49. } else {
  50. return false;
  51. }
  52. }
  53.  
  54. bool Empty(){
  55. if (size == 0) {
  56. return true;
  57. } else {
  58. return false;
  59. }
  60. }
  61.  
  62. void insertatend(int z){
  63. if (size < maxSize) {
  64. arr[size] = z;
  65. size++;
  66. } else {
  67. cout << "Array is complete " << endl;
  68. }
  69. }
  70.  
  71. void Delete(){
  72. if (size > 0) {
  73. size--;
  74. cout<<"deleting for end array Successful"<<endl;
  75. }
  76. }
  77.  
  78. void deletval(){
  79. int c;
  80. bool found=false;
  81. cout<<"Enter The Value For Deleting : "<<endl;
  82. cin>>c;
  83. for(int i=0;i<size;i++){
  84. if(arr[i]==c){
  85. arr[i]=NULL;
  86. found=true;
  87. cout<<"delete successful "<<endl;
  88. cout<<"Index "<<i<<" is Empty Now !"<<endl;
  89. break;
  90. }
  91. }if(found==false){
  92. cout<<"deleted failed "<<endl;
  93. }
  94. }
  95. };
  96.  
  97. int main() {
  98.  
  99. return 0;
  100. }
  101.  
Success #stdin #stdout 0.01s 5268KB
stdin
Standard input is empty
stdout
Standard output is empty