/
vlad777
/
Ivanov
Обзор
Документация
Войти
/
vlad777
/
Ivanov
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
sortbubble.cpp
48 строк
694 B
vlad777
upload files
07 май 2025, 13:33
07 май 2025, 13:33
4be374a
Код
Авторство
О чём код?
#include <iostream> #include <iostream> using namespace std; class Sort { public: int n, a[10]; public: void print() { for (int i=0; i<this->n; i++ ) { cout << this->a[i]<< " "; } cout << "\n "; } void input() { for (int i=0; i<this->n;i++) { cout << " a["<<i<<"]="; cin>>this->a[i]; } } void sort_bubble () { int i,j,t; for (i=0;i<n-1;i++) for(j=0;j<n-i-1;j++) if (this->a[j]>this->a[j+1]) { t=this->a[j]; this->a[j]=this->a[j+1]; this->a[j+1]=t; } } }; int main() { setlocale(LC_ALL, "Russian"); Sort sort; sort.n = 10; sort.input(); sort.sort_bubble(); sort.print(); return 0; }