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...
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