how to sort an array in c++
C++
// C++ program to demonstrate default behaviour of
// sort() in STL.
#include <bits/stdc++.h>
using namespace std;
int main()
{
int arr[] = {1, 5, 8, 9, 6, 7, 3, 4, 2, 0};
int n = sizeof(arr)/sizeof(arr[0]);
sort(arr, arr+n);
cout << "\nArray after sorting using "
"default sort is : \n";
for (int i = 0; i < n; ++i)
cout << arr[i] << " ";
return 0;
}
#include <bits/stdc++.h>
using namespace std;
#define size(arr) sizeof(arr)/sizeof(arr[0]);
int main(){
int a[5] = {5, 2, 6,3 ,5};
int n = size(a);
sort((a), a + n);
for(int i = 0; i < n; i++){
cout << a[i];
}
return 0;
}
// C++ program to demonstrate default behaviour of
// sort() in STL.
#include <bits/stdc++.h>
using namespace std;
int main()
{
int arr[] = {1, 5, 8, 9, 6, 7, 3, 4, 2, 0};
int n = sizeof(arr)/sizeof(arr[0]);
sort(arr, arr+n);
cout << "\nArray after sorting using "
"default sort is : \n";
for (int i = 0; i < n; ++i)
cout << arr[i] << " ";
return 0;
}
Also in C++:
- Title
- string substr c++
- Category
- C++
- Title
- how to check datatype of a variable in c++
- Category
- C++
- Title
- repeating character in c++
- Category
- C++
- Title
- how to compare two strings lexicographically in c++
- Category
- C++
- Title
- convert char to string - c++
- Category
- C++
- Title
- Rectangle area hackerrank solution in c++
- Category
- C++
- Title
- how to iterate trough a vector in c++
- Category
- C++
- Title
- Find a element in a map C++
- Category
- C++
- Title
- hashset in c++
- Category
- C++
- Title
- c++ loop through int array
- Category
- C++
- Title
- swapo algorit
- Category
- C++
- Title
- error: invalid conversion from 'Node*' to 'int'
- Category
- C++
- Title
- c++ ros subscriber
- Category
- C++
- Title
- preorder traversal
- Category
- C++
- Title
- iterate const vector
- Category
- C++
- Title
- Runtime Error: Runtime ErrorAbort signal from abort(3) (SIGABRT)
- Category
- C++
- Title
- How to traverse in a tree iterative C++
- Category
- C++
- Title
- split string at index c++
- Category
- C++
- Title
- multiset c++
- Category
- C++
- Title
- unordered_map c++ insert
- Category
- C++
- Title
- declare vectors c++
- Category
- C++
- Title
- how long can a c++ string be
- Category
- C++
- Title
- dfs in c++
- Category
- C++
- Title
- Html tab
- Category
- C++
- Title
- c++ multiple inheritance diamond problem
- Category
- C++
- Title
- how to round to nearest whole number unity
- Category
- C++
- Title
- free or delete in c++
- Category
- C++
- Title
- gcd in c++
- Category
- C++
- Title
- min coin change problem dp
- Category
- C++
- Title
- how to print for limited decimal values in c++
- Category
- C++
- Title
- struct c++
- Category
- C++
- Title
- c++ sql
- Category
- C++
- Title
- deque c++
- Category
- C++
- Title
- advanced c++ topics
- Category
- C++
- Title
- c++ char to int
- Category
- C++
- Title
- range based for loop c++
- Category
- C++
- Title
- matrix class in c++
- Category
- C++
- Title
- mkdir boost filesystem
- Category
- C++
- Title
- how to output text in c++
- Category
- C++
- Title
- FInd the element which appears more than n/2 times C++
- Category
- C++
- Title
- set precision in c++
- Category
- C++
- Title
- how to delete a node c++
- Category
- C++
- Title
- inheritance protected in c++
- Category
- C++
- Title
- zeros of array c++
- Category
- C++
- Title
- is TLE means my code is correct but taking more time to computr
- Category
- C++
- Title
- std string find character c++
- Category
- C++
- Title
- what is meaning of 64 bit integer in c++
- Category
- C++
- Title
- is not a nonstatic data member or base class of class
- Category
- C++
- Title
- c++ convert int to cstring
- Category
- C++
- Title
- Application of c++ in youtube program
- Category
- C++
- Title
- knapsack
- Category
- C++
- Title
- how to check sqrt of number is integer c++
- Category
- C++
- Title
- c++ movment
- Category
- C++
- Title
- regexp_like oracle c++
- Category
- C++
- Title
- how to print nth palindrome number in c++
- Category
- C++
- Title
- erase in set
- Category
- C++
- Title
- C++ remove element from set
- Category
- C++
- Title
- double ended queue in c++ stl
- Category
- C++
- Title
- c++ iterate through constant list
- Category
- C++
- Title
- worker class c++
- Category
- C++
- Title
- copy a part of a vector in another in c++
- Category
- C++
- Title
- how to turn int into string c++
- Category
- C++
- Title
- solve linear equations geeksforgeeks
- Category
- C++
- Title
- get elements of 2d array c++
- Category
- C++
- Title
- prims c++
- Category
- C++
- Title
- recursion in cpp with reference
- Category
- C++
- Title
- two sum problem in c++
- Category
- C++
- Title
- cpp how to create an object of template class
- Category
- C++
- Title
- traverse a map
- Category
- C++
- Title
- c++ code to print hello world
- Category
- C++
- Title
- residuo en lenguaje c
- Category
- C++
- Title
- c++ how to loop through a vector but not the last element
- Category
- C++
- Title
- c++ transform
- Category
- C++
- Title
- object slicing in c++
- Category
- C++
- Title
- nginx linux
- Category
- C++
- Title
- find_if c++
- Category
- C++
- Title
- making random numbers in c++
- Category
- C++
- Title
- how to remove maximum number of characters in c++ cin,ignore
- Category
- C++
- Title
- pair in c++
- Category
- C++
- Title
- error: ‘memset’ was not declared in this scope in cpp
- Category
- C++
- Title
- cloud hosting
- Category
- C++
- Title
- how to print 5 precision float in c++
- Category
- C++
- Title
- pbds in c++
- Category
- C++
- Title
- c++ loop through array
- Category
- C++
- Title
- and or in c++
- Category
- C++
- Title
- c++ short if
- Category
- C++
- Title
- arduino delay millis
- Category
- C++
- Title
- Given an undirected graph, count the number of connected components.
- Category
- C++
- Title
- how to run a c++ program in the background
- Category
- C++
- Title
- runtime error in c++
- Category
- C++
- Title
- iterar un map c++
- Category
- C++
- Title
- C++ and endl
- Category
- C++
- Title
- c++ compare char
- Category
- C++
- Title
- c++ crash windows
- Category
- C++
- Title
- cin.ignore
- Category
- C++
- Title
- cpp create lambda with recursion
- Category
- C++
- Title
- c++ show time elapsed
- Category
- C++
- Title
- screen record ios simulator
- Category
- C++
- Title
- initialize int c++
- Category
- C++
- Title
- how to convert a string to a double c++
- Category
- C++