array sort 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;
}
// 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 <iostream>
2 #include <array>
3 #include <string>
4 #include <algorithm>
5
6 using namespace std;
7
8 int main(){
9 array<string, 4> colours = {"blue", "black", "red", "green"};
10 for (string colour : colours){
11 cout << colour << ' ';
12 }
13 cout << endl;
14 sort(colours.begin(), colours.end());
15 for (string colour : colours){
16 cout << colour << ' ';
17 }
18 return 0;
19 }
66
20
21 /*
22 Output:
23 blue black red green
24 black blue green red
25 */
Also in C++:
- Title
- call by reference c++ example
- Category
- C++
- Title
- binary tree search
- Category
- C++
- Title
- string to vector c++
- Category
- C++
- Title
- powers of 2 in cpp
- Category
- C++
- Title
- c++ random numbers
- Category
- C++
- Title
- array<string, 7> c++
- Category
- C++
- Title
- c++ server service ros
- Category
- C++
- Title
- qt graphics scene map cursor position
- Category
- C++
- Title
- check for bst
- Category
- C++
- Title
- generate random double c++
- Category
- C++
- Title
- properties of a set c++
- Category
- C++
- Title
- std::iomanip c++
- Category
- C++
- Title
- Temporary file using MSFT API in cpp
- Category
- C++
- Title
- c++ loop through int array
- Category
- C++
- Title
- c++ excel blank cells
- Category
- C++
- Title
- how to cout in c++
- Category
- C++
- Title
- c++ wait for user input
- Category
- C++
- Title
- c++ overloaded == operator
- Category
- C++
- Title
- c++ passing two dimensional array to function
- Category
- C++
- Title
- getting a random letter in c++
- Category
- C++
- Title
- c++ parse int
- Category
- C++
- Title
- compare function in sort c++ stl
- Category
- C++
- Title
- user input c++
- Category
- C++
- Title
- how to use max_element in c++ with vector
- Category
- C++
- Title
- transpose matrix eigen c++
- Category
- C++
- Title
- convert int to string c++
- Category
- C++
- Title
- how to print a string to console in c++
- Category
- C++
- Title
- how to convert qt string to string
- Category
- C++
- Title
- create copy of range of string c++
- Category
- C++
- Title
- 2927260.eps 2927262.jpg 2927263.ai License free.txt License premium.txt
- Category
- C++
- Title
- initialize int c++
- Category
- C++
- Title
- sieve of eratosthenes c++
- Category
- C++
- Title
- min heap declaration in c++ stl
- Category
- C++
- Title
- set of vectors c++
- Category
- C++
- Title
- counting valleys hackerrank solution in c++
- Category
- C++
- Title
- c++ return multiple values
- Category
- C++
- Title
- how to append one vector to another c++
- Category
- C++
- Title
- index string c++
- Category
- C++
- Title
- c++ get length of array
- Category
- C++
- Title
- ios_base::sync_with_stdio(false);cin.tie(NULL);
- Category
- C++
- Title
- maximum subarray sum equal with K in c++
- Category
- C++
- Title
- hohw toparse a string in c++
- Category
- C++
- Title
- sum of two numbers c++
- Category
- C++
- Title
- c++ how to skip the last element of vector
- Category
- C++
- Title
- how to read and write in a file c++
- Category
- C++
- Title
- bfs in C++
- Category
- C++
- Title
- decimal to hex cpp
- Category
- C++
- Title
- get elements of 2d array c++
- Category
- C++
- Title
- c++ operator overloading
- Category
- C++
- Title
- floor() in c++
- Category
- C++
- Title
- mao two drivers c++
- Category
- C++
- Title
- longest common subsequence
- Category
- C++
- Title
- how to concatinate two strings in c++
- Category
- C++
- Title
- COnvert string to char * C++
- Category
- C++
- Title
- c++ rainbow text
- Category
- C++
- Title
- reverse a linked list using recursion
- Category
- C++
- Title
- c++ string to vector int
- Category
- C++
- Title
- new c++
- Category
- C++
- Title
- ternary operator c++
- Category
- C++
- Title
- basic ex of maps in c++
- Category
- C++
- Title
- c++ char to int
- Category
- C++
- Title
- newline in c++
- Category
- C++
- Title
- c++ function return pointer to itself
- Category
- C++
- Title
- heredar constructor c++
- Category
- C++
- Title
- binary search stl in c++
- Category
- C++
- Title
- number of islands leetcode code
- Category
- C++
- Title
- how to create object in c++
- Category
- C++
- Title
- how to make a switch case statement in c++
- Category
- C++
- Title
- c++ throw exception
- Category
- C++
- Title
- string substr c++
- Category
- C++
- Title
- ternary search c++
- Category
- C++
- Title
- what is order in of preeendence in float, int, char, bool
- Category
- C++
- Title
- passing array to function c++ pointer
- Category
- C++
- Title
- prims c++
- Category
- C++
- Title
- preorder traversal
- Category
- C++
- Title
- how to put a class in a .h file c++
- Category
- C++
- Title
- how to know the correct class of objects cpp
- Category
- C++
- Title
- range based for loop c++ with reference
- Category
- C++
- Title
- append string to another string c++
- Category
- C++
- Title
- border radius layout android xml
- Category
- C++
- Title
- how to convert n space separated integers in c++
- Category
- C++
- Title
- Given an undirected graph, count the number of connected components.
- Category
- C++
- Title
- Shortest Distance in a Maze
- Category
- C++
- Title
- declare vectors c++
- Category
- C++
- Title
- how to output text in c++
- Category
- C++
- Title
- ceil in c++
- Category
- C++
- Title
- how to have a queue as a parameter in c++
- Category
- C++
- Title
- how to convert string to int c++
- Category
- C++
- Title
- c++ give options string
- Category
- C++
- Title
- array 2d to 1d
- Category
- C++
- Title
- bellman ford algorithm cp algorithm
- Category
- C++
- Title
- residuo en lenguaje c
- Category
- C++
- Title
- in c, is class uppercase or lowercase
- Category
- C++
- Title
- c++ class inheritance
- Category
- C++
- Title
- max heap c++ stl;
- Category
- C++
- Title
- double pointers C++
- Category
- C++
- Title
- ue4 c++ overlapping functions cpp setup
- Category
- C++
- Title
- how to round to nearest whole number unity
- Category
- C++
- Title
- initialize 2d array c++
- Category
- C++
- Title
- stl sort in c++
- Category
- C++