Sign in
or
Register
Courses
Textbook
Compiler
Contests
Topics
Courses
C++. Containers
Using set
Module:
Using set
Problem
3
/10
Using set with a comparator
Theory
Click to read/hide
Using
set
with a comparator
An example of a comparator to create an ordered set in descending order.
struct cmp { bool operator() ( int a, int b) const{ return a > b; } };
Using a comparator when creating a
set
.
set <int, cmp> s;
Problem
Complete
the program with a comparator to solve the following problem.
Given
N
natural numbers. Output the set sorted by the sum of the digits of the number.
Examples
#
Input
Output
1
4
123 321 34 23
23 123 34
1000
ms
256 Mb
Rules for program design and list of errors in automatic problem checking
Teacher commentary