Answers for "c++ sort and return array"

C++
1

C++ array sort method

#include <algorithm>
#include <iostream>
#include <array>
using namespace std;

int main() {
    array<int, 5> arraysort{ 4,2,3,5,1 };
    sort(arraysort.begin(), arraysort.end());
    for (int i = 0; i < arraysort.size(); i++) {
        cout << arraysort[i] << " ";
    }
	return 0; 
}
Posted by: Guest on August-09-2021
2

how to sort array in c++

#include <algorithm>

int main(){
  int v[2000];
  std::sort(std::begin(v), std::end(v));
}
Posted by: Guest on October-15-2021

Browse Popular Code Answers by Language