olyska20 Posted November 4, 2008 Report Share Posted November 4, 2008 помогите плиз надо осортировать массив целых чисел 4мя способами --пузырёк, Шелла, метод прямого включения и выбора. Пузырёк я сделала а дальше запуталась((((помогите прошу очень . Спасибо заранее. #include "stdafx.h" #include <iostream.h> #include <iomanip.h> #include <stdio.h> #include <stdlib.h> #include <time.h> #include <string.h> const int N = 20; class Array { int *a; int size; public: Array(); ~Array(); int n; void print(); void sortPysirek(); void sortVstavka(int *, int); }; Array::Array() { a = new int[N]; for (int i = 0; i < 20; i++) a = rand()%100; } Array::~Array(){ delete[] a; } void Array::print() { for (int i = 0; i < N; i++) cout<<a<<endl; } void Array::sortPysirek(){ int hold; for (int prox = 1; prox < N; prox++) for (int i = 0; i < N - 1; i++) if(a > a){ hold = a; a = a; a = hold;} cout<<"Elementi v poriadke vosrastania : "<<endl; for(int i = 0; i < N; i++) cout<<setw(3)<<a; } int main(int argc, char* argv[]) { srand(time(NULL)); Array a; a.print(); cout<<"-------------------------------"<<"METOD PYSIRKA"<<"-----------------------------------"<<endl; a.sortPysirek(); return 0; } Link to comment Share on other sites More sharing options...
Тролль Posted November 4, 2008 Report Share Posted November 4, 2008 olyska20: В Википедии приведены уже готовые программы на C++ сортировки всеми этими, и еще и многими другими, методами. Смотри тут. Link to comment Share on other sites More sharing options...
olyska20 Posted November 5, 2008 Author Report Share Posted November 5, 2008 большое спасибо ты мне так помогаешь)))) :rolleyes: Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now