0
program in c++ to rearrange the array in such a manner that all no.s divisible by 5 are stored first followed by the rest.
2 ответов
+ 3
// If you can use built in functions...
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
int arr[5]={1,2,3,10,5};
sort(arr,arr+5, [](int a, int b)->bool
{return a%5<=b%5&&a<b;});
for(int i:arr) cout<<i<<endl;
// Prints 5,10,1,2,3.
}
+ 2
use some sorting algorithm and use your condition to sort it