Jump to content

сортировка массива


Recommended Posts

помогите плиз надо осортировать массив целых чисел 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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...