Skip to content

Commit 01ee110

Browse files
Владимир СеверовВладимир Северов
authored andcommitted
17.03.22 00:17 - Bugs Fix
1 parent 277ad58 commit 01ee110

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

M2-LW-8/M2-LW-8/Source.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
#include <cstdlib>
22
#include <iostream>
33
#include <vector>
4+
#include <list>
45

56
template<class IT>
67
void sort(IT beg, IT end)
78
{
8-
for (IT i = beg; i < end - 1; ++i) {
9-
for (IT j = i + 1; j < end; ++j) {
9+
for (IT i = beg; i != end; ++i) {
10+
for (IT j = beg; j != end; ++j) {
1011
if (*j < *i) {
1112
std::swap(*i, *j);
1213
}
@@ -37,6 +38,13 @@ int main() {
3738
}
3839
std::cout << std::endl;
3940

41+
std::list<double> l = { 123.0, 3.0, 0.0, 13212.0, -100.0 };
42+
sort(l.begin(), l.end()); // vec: -100.0, 0.0, 3.0, 123.0, 13212.0
43+
for (size_t i = 0; i < 5; ++i) {
44+
std::cout << vec.at(i) << " ";
45+
}
46+
std::cout << std::endl;
47+
4048
system("pause");
4149
return 0;
4250
}

0 commit comments

Comments
 (0)