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