An array of k characters is specified. Calculate the sum S first 20 negative elements of an array that are multiples of 5 . Remove from the array elements whose values ​​are equal in absolute value to S

Here is the version of the program that performs the sum finding and searches for elements that are modulo S , but line 29 has no body after if , because I have no idea how to remove it from the array.

 #include <iostream> #include <array> #include <cstdlib> using namespace std; int main(){ setlocale (0,"Rus"); int i,j=0,sum=0; const int k=40; array <int, k> arr={}; // Создается массив, все элементы которого инициализированы нулями for(i=0;i<k;i++){ arr[i]=-200+rand()%300; cout<<arr[i]<<endl; } for(i=0;i<k,j<20;i++){ if(arr[i]<0&&arr[i]%5==0) sum+=arr[i]; // Сумма 20 отрицательных элементов j++; } for(i=0;i<k;i++){ if(arr[i]==sum||arr[i]==-sum) // arr[i] } return 0; } 
  • Please add to the question your attempts to solve the problem. The reason why this is necessary . Thank. - Sasha Chernykh
  • The array container has a fixed size specified at compile time and does not support the delete operation. If you want to delete, use vector . - VTT
  • It’s a pity (in the lab it’s said to do the above task using a sequential container array. Or maybe there’s a tricky way to get around it? Not completely remove it somehow, it can be removed secretly. Well, you really need to do it like in a task - Razor
  • In the condition of the problem, is it told to use std :: array, or is it just told to use an array? - KoVadim
  • the condition says to perform the task using a sequential container array - Razor of the mind

0