Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

лабораторные работы / сортировка

.docx
Скачиваний:
27
Добавлен:
28.01.2014
Размер:
13.55 Кб
Скачать

#include "stdafx.h"

#include <stdio.h>

#include <stdlib.h>

#include <time.h>

#include <math.h>

#include <conio.h>

#include <string.h>

int a[15];

int b[15];

void Outpute(void)

{

for(int i=0; i<=14;i++)

printf("%i ",a[i]);

}

void Outputo(void)

{

for(int i=0; i<=14;i++)

printf("%i ",b[i]);

}

void Bubbles (int prototy)

{

printf("\n");

int c;

if(prototy==1)

for(int i=0; i<=14; i++)

{

for(int j=i; j<=15; j++)

{

if(a[i]<a[j])

{

c=a[i];

a[i]=a[j];

a[j]=c;

}

}

printf("\n");

Outpute();

}

if(prototy==2)

for(int i=0; i<=14; i++)

{

for(int j=i; j<=14; j++)

{

if(a[i]>a[j])

{

c=a[i];

a[i]=a[j];

a[j]=c;

}

}

printf("\n");

Outpute();

}

}

void Paste (int prototy)

{

int maxmin=a[0];

int nomber=0;

if(prototy==1)

{

for(int j=0;j<=14;j++)

{

for(int i=0;i<=14;i++)

{

if (a[i]<maxmin)

{

maxmin=a[i];

nomber=i;

}

}

b[j]=maxmin;

a[nomber]=100;

Outputo;

}

}

}

void Sort (int typ, int prototyp)

{

//clrscr();

if(typ==1) Bubbles(prototyp);

if(typ==2) Paste(prototyp);

/*

if(typ==3) Chose(prototyp);

if(typ==4) Combine(prototyp);

if(typ==5) FR(prototyp);

*/

}

void main()

{

int type,prototype;

for (int i=0; i<=14;i++)

{

a[i]=rand()%99+1;

printf("%i ",a[i]);

}

do

{

printf("\n\n1 - Bubbles \n2 - Paste \n3 - Chose \n4 - Combine \n5 - Fast&Reinforcement\n");

printf("> ");

scanf("%i",&type);

}

while((type<=0)||(type>=6));

do

{

printf("\n\n1 - Up \n2 - Down\n");

printf("> ");

scanf("%i",&prototype);

}

while((prototype<=0)||(prototype>=3));

Sort(type,prototype);

getch();

}