fork download
  1.  
  2. #include <iostream>
  3.  
  4. using namespace std;
  5. class Arr{
  6. private:
  7. long long virtualsize;
  8. long long size_index;
  9. long long *arr;
  10. public:
  11. Arr(long long vs){
  12. virtualsize=vs;
  13. size_index=0;
  14. arr=new long long[virtualsize];}
  15.  
  16.  
  17. void insirt_index(int si){
  18.  
  19. if(si>virtualsize){
  20. cout<<" you must read first line correctly!"<<endl;
  21. }
  22. else{
  23. cout<<" now! enter the next elements: "<<endl;
  24.  
  25. for(int i=0;i<si;i++){
  26. int b=i+1;
  27. cout<<" ( "<<b<< " ) ";
  28. cin>>arr[i];
  29. size_index++;
  30. }}}
  31.  
  32. void dis(){
  33.  
  34. cout<<" knew that tha max size is : "<<virtualsize<<endl;
  35. cout << " your elements now is : "<<size_index<<endl;
  36. for(int i=0;i<size_index;i++){
  37. int b=i+1;
  38. cout<<" ( "<<b<< " ) = "<<arr[i]<<endl;}
  39. }
  40.  
  41. void addend(int end){
  42.  
  43. if(size_index==virtualsize){
  44. cout<<"sorry! the array is full"<<endl;
  45. }
  46. else{
  47. arr[size_index]=end;
  48. size_index++;
  49. cout << " your elements now is : "<<size_index<<endl;
  50. for(int i=0;i<size_index;i++){
  51. int b=i+1;
  52.  
  53. cout<<" ( "<<b<< " ) = "<<arr[i]<<endl;}}}
  54.  
  55. void cut(int index){
  56.  
  57. if(index==size_index){
  58. size_index--;
  59. cout <<" after delating "<<endl;
  60. for(int i =0;i<size_index;i++){
  61. int b=i+1;
  62. cout<<" ( "<<b<< " ) = "<<arr[i]<<endl;}}}
  63.  
  64. void find(){
  65. bool f=false;
  66. int in;
  67. cout <<" enter value to search in your array :"<<endl;
  68. int value;
  69. cin>>value;
  70. for(int i=0;i<size_index;i++)
  71. if(arr[i]==value){
  72. f=true;
  73. in =i;
  74. break;
  75. }
  76. if(f==true){
  77. cout<< " ok we found your value in index : "<<in<<endl;
  78. }
  79. else {
  80. cout<<" ops! we cant find your value :"<<endl;
  81. }
  82. }
  83.  
  84. };
  85.  
  86. int main()
  87. {
  88. long long size;
  89. int end,vs,cut;
  90.  
  91. cout<<" firstly insert your max size >> " ;
  92. cin>>size;
  93. Arr arr2(size);
  94. cout<<" now enter the size order : ";
  95.  
  96. cin>>vs;
  97. arr2.insirt_index(vs);
  98. arr2.dis();
  99. cout << " enter end value to test is there empety placce: "<<endl;
  100. cin>>end;
  101. arr2.addend(end);
  102. cout<<" enter your index where you want cut: "<<endl;
  103. cin>>cut;
  104. arr2.cut(cut);
  105. arr2.find();
  106. cout << " your array after all thing is "<<endl;
  107. arr2.dis();
  108.  
  109. return 0;
  110. }
Success #stdin #stdout 0.01s 5288KB
stdin
 firstly insert your max size >> 5
 now enter the size order : 4
 now! enter the next elements: 
 ( 1 )3
 ( 2 )4
 ( 3 )6
 ( 4 )8
 knew that tha max size is : 5
 your elements now is : 4
 ( 1 )  = 3
 ( 2 )  = 4
 ( 3 )  = 6
 ( 4 )  = 8
 enter end value to test is there empety placce: 
8
 your elements now is : 5
  ( 1 )  = 3
  ( 2 )  = 4
  ( 3 )  = 6
  ( 4 )  = 8
  ( 5 )  = 8
 enter your index where you want cut: 
4
 enter value to search in your array :
6
 ok we found your value in  index : 2
 your array after  all thing is 
 knew that tha max size is : 5
 your elements now is : 5
 ( 1 )  = 3
 ( 2 )  = 4
 ( 3 )  = 6
 ( 4 )  = 8
 ( 5 )  = 8
stdout
 firstly insert your max size >>  now enter the size order :  you must read first line correctly!
 knew that tha max size is : 0
 your elements now is : 0
 enter end value to test is there empety placce: 
sorry! the array is full
 enter your index where you want cut: 
 enter value to search in your array :
 ops! we cant find your value :
 your array after  all thing is 
 knew that tha max size is : 0
 your elements now is : 0