Анализ некоторых видов сортировок
Курсовой проект - Компьютеры, программирование
Другие курсовые по предмету Компьютеры, программирование
10,300+40*7,430);(300,420,"Vremia konca sortirovki:");(300+29*7,420,chas);(300+31*7,420,":");(300+32*7,420,min);(300+34*7,420,":");(300+35*7,420,sec);(300+37*7,420,".");(300+38*7,420,hund);s2=t2.ti_hund;=t2.ti_hour;=r2-r;time2=r2*3600+t2.ti_min*60+t2.ti_sec+(s2/100);=time2-time1;(time2,time,10);(s1>s2) s2=100+s2-s1;s2=s2-s1;(s2,timer,10);(i=0;timer[i];i++);
if (i==1) {
timer[1]=timer[0];
timer[0]=0;
timer[2]=\0;
}(300,440,"Vremia sortirovki:");(300+21*7,440,time);(300+22*7,440,".");(300+23*7,440,timer);
}
puzir(int*& kop,int razmer,unsigned long int& iter) {temp,a;=0;(int i=1;i<razmer;i++) { a=i;((a) && (kop[a]<kop[a-1])) {
temp=kop[a-1];
kop[a-1]=kop[a];
kop[a]=temp;
a--;
iter++;
}
}
}vstavka(int*& kop,int razmer,unsigned long int& iter) {min,index,temp;=0;(int k=0;k<razmer;k++){ min=kop[k]; index=k;
for (int i=k;i<razmer;i++) {
if (min>kop[i]) {
min=kop[i];
index=i;
iter++;
}
}=kop[k];[k]=kop[index];[index]=temp;
}
}protalkivanie(int*& kop,int razmer,unsigned long int& iter) {temp;=0;(int k=0;k<razmer-1;k++) {
for (int i=0;i<razmer-1;i++) {
if (kop[i]>kop[i+1]) {
temp=kop[i];
kop[i]=kop[i+1];
kop[i+1]=temp;
iter++;
}
}
}
}Pirmidalina9(int*& kop,int razmer,unsigned long int& iter) {temp,b,z,g;=0;(long int i=razmer-1;i>=0;i--) {[i]=random(razmer);
}(z=0;z<razmer;z++) { b=1; i=z;
while ((b) && (i>0)) { iter++;
if ((i%2==0) && (kop[i]>kop[i/2-1])) {
temp=kop[i];
kop[i]=kop[i/2-1];
kop[i/2-1]=temp;
i=i/2-1;
}
else if ((i%2==1) && (kop[i]>kop[i/2])) {
temp=kop[i];
kop[i]=kop[i/2];
kop[i/2]=temp;
i=i/2;
}
else b=0;
}
}=razmer;(g>0) {=kop[0];[0]=kop[g-1];[g-1]=temp;-;
i=0; b=1;
while ((b) && (i*2+1<g)) { iter++;
if ((kop[i]=kop[i*2+2]) && (i*2+1<g)) {
temp=kop[i];
kop[i]=kop[i*2+1];
kop[i*2+1]=temp;
i=i*2+1;
}
else if ((kop[i]=kop[i*2+1]) && (i*2+2<g)){
temp=kop[i];
kop[i]=kop[i*2+2];
kop[i*2+2]=temp;
i=i*2+2;
}
else if ((kop[i]<kop[i*2+1]) && (kop[i]<kop[i*2+2])) {
if ((kop[i*2+1]<kop[i*2+2]) && (i*2+2<g)) {
temp=kop[i];
kop[i]=kop[i*2+2];
kop[i*2+2]=temp;
i=i*2+2;
}
else {
temp=kop[i];
kop[i]=kop[i*2+1];
kop[i*2+1]=temp;
i=i*2+1;
}
}
else b=0;
}
}
}massiv(int*& kop,int razmer,int metod) {(metod==1) {
for (int i=0;i<razmer;i++)
kop[i]=random(razmer);
}(metod==2) {
for (int i=0;i<razmer;i++)
kop[i]=i;
}(metod==3) {
for (int i=razmer-1;i>=0;i--)
kop[i]=razmer-i-1;
}0;
}
Файл FILE.CPP
#include
#include
File(int*&kop,intk,intrazmer){*out;((out=fopen("c:\\BORLANDC\\BIN\\1.txt","w"))==NULL){(stderr,"Cannotopenoutputfile.\n");1;}(k==1){">#include File(int*& kop,int k,int razmer) {*out;((out = fopen("c:\\BORLANDC\\BIN\\1.txt", "w")) == NULL) {(stderr, "Cannot open output file.\n");1; }(k==1) {
for (int i=0; i<razmer; i++) {
fprintf(out, "%d ", kop[i] );
}
}(k==0) {
for (int i=razmer-1; i>=0; i--) {
fprintf(out, "%d ", kop[i] );
}
}(out);0;
}File1(int*& kop,int razmer) {*out;((out = fopen("c:\\BORLANDC\\BIN\\2.txt", "w")) == NULL) {(stderr, "Cannot open output file.\n");1; }
for (int i=0; i<razmer; i++) {
fprintf(out, "%d ", kop[i] );
}(out);0;
}