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

С++ ЕНФ / LABA 6 / 62 shell01

.CPP
Скачиваний:
13
Добавлен:
25.05.2014
Размер:
1.1 Кб
Скачать
#include <iostream.h>
#include <conio.h>
#include <stdlib.h>
#include <string.h>

void sort(char* arr[], int N)     
{
 int i,j; char *b; int g,h,m;
 h=N;m=2;
 for (int k=m;k>=0;k--)
 {h=h/2; //g=h;
 for(j=h;j<m;j++)
 {
  i=j-h; b=arr[j];
  do
  {if((strlen(arr[i]))<=(strlen(b))) {arr[i+h]=b;break;}
    else {(arr[i+1])=(arr[i]);i=i-h;};}
  while (i>=0);
  }
 }
}

void main()
{int i=0;
 char *M[1000];
 float max=0;
 clrscr();
 cout << "\n\nEta programma osuschestvljaet sortirovku massiva strok v porjadke ubjivanija\n";
 cout << "dlin strok\n";
 do
  {cout<<" vv. chislo n, ono dolgno bit >=1 i celim \n\n";
    cin>>max;}
   while ((max-int(max)!=0) || (max<1));

 for(i=0; i<max; i++)
  {
   cout<<"Vvedite "<<(i+1)<<"stroku \n";
   cin>>M[i];
   M[i+1]=M[i]+(strlen(M[i])+1);
  };
 clrscr();
 cout<<endl<<"ishodnjij massiv:"<<endl;
 for(i=0; i<max; i++)
  cout<<endl<<" M ["<<(i+1)<<"]: '"<<M[i]<<"'";
 sort(M, max);
 cout<<endl<<"otsortirovannjij massiv:"<<endl;
 for(i=0; i<max; i++)
   cout<<endl<<"M ["<<(i+1)<<"]: '"<<M[i]<<"'";
 getch();
}
Соседние файлы в папке LABA 6