Stránka: 1 z 1
| [ Príspevkov: 23 ] | |
Autor | Správa |
---|
Registrovaný: 05.06.09 Prihlásený: 23.03.14 Príspevky: 557 Témy: 23 | 23 Bydlisko: near DK |
Ahojte. Prosím Vás mohli by ste sa na to mrknúť? Zajtra to potrebujem odovzdať a nejak zle mi to triedi..
Kód: program shellsortAselectsort; uses crt,dos;
procedure ShellSort (var c: array of integer; n,h : integer); var aux,i : integer; begin if h > 0 then begin if n > h then begin ShellSort(c,n - h,h); if c[n] < c[n - h] then begin aux:= c[n]; i:= n; repeat c[i] := c[i - h]; i := i - h; until (i = h) or (aux > c[i - h]); c[i] := aux; end; end; ShellSort(c,n,h div 3); end; end;
procedure SelectSort (var c1: array of integer; p: integer); var i,j,min,tmp: integer; begin for i:=0 to (p - 1) do begin min:=i; for j:=(i+1) to (p - 1) do begin if (c1[j] < c1[min]) then min:=j; end; tmp:=c1[i]; c1[i]:=c1[min]; c1[min]:=tmp; end; end;
var pole1: array [0..5000] of integer; pole2: array [0..10000] of integer; pole3: array [0..15000] of integer; p : array [0..50] of integer; i : integer; h,m,s,ss,hod,min,sek,s100: word;
begin clrscr; writeln('Klaudia Martvonova'); writeln('zadanie c.5'); writeln; randomize; textcolor(4); writeln ('SELECTSORT');
for i:= 0 to 5000 do pole1[i]:=random(15000); gettime(h,m,s,ss); SelectSort(pole1,i); gettime(hod,min,sek,s100); if s100>ss then writeln(hod-h,':',min-m,':',sek-s,':',s100-ss) else writeln(hod-h,':',min-m,':',sek-s,':',s100);
for i:= 0 to 10000 do pole2[i]:=random(15000); gettime(h,m,s,ss); SelectSort(pole2,i); gettime(hod,min,sek,s100); if s100>ss then writeln(hod-h,':',min-m,':',sek-s,':',s100-ss) else writeln(hod-h,':',min-m,':',sek-s,':',s100);
for i:= 0 to 15000 do pole3[i]:=random(15000); gettime(h,m,s,ss); SelectSort(pole3,i); gettime(hod,min,sek,s100); if s100>ss then writeln(hod-h,':',min-m,':',sek-s,':',s100-ss) else writeln(hod-h,':',min-m,':',sek-s,':',s100);
textcolor(15); writeln; writeln('SHELLSORT'); gettime(h,m,s,ss); ShellSort(pole1,5000,1); gettime(hod,min,sek,s100); if s100>ss then writeln(hod-h,':',min-m,':',sek-s,':',s100-ss) else writeln(hod-h,':',min-m,':',sek-s,':',s100); gettime(h,m,s,ss); ShellSort(pole2,10000,1); gettime(hod,min,sek,s100); if s100>ss then writeln(hod-h,':',min-m,':',sek-s,':',s100-ss) else writeln(hod-h,':',min-m,':',sek-s,':',s100); gettime(h,m,s,ss); ShellSort(pole3,15000,1); gettime(hod,min,sek,s100); if s100>ss then writeln(hod-h,':',min-m,':',sek-s,':',s100-ss) else writeln(hod-h,':',min-m,':',sek-s,':',s100);
textcolor(2); writeln; writeln('SELECTSORT'); textcolor(9); for i:=1 to 20 do begin p[i]:=random(20); write(p[i], ' '); end; writeln; writeln; textcolor(8); writeln('TRIEDENIE PRVKOV'); textcolor(5); SelectSort(p, 20); for i:=1 to 20 do begin write(p[i], ' '); end;
textcolor(2); writeln; writeln; writeln('SHELLSORT'); textcolor(9); for i:=1 to 20 do begin p[i]:=random(20); write(p[i], ' '); end; writeln; textcolor(8); writeln; writeln('TRIEDENIE PRVKOV'); textcolor(5); ShellSort(p, 20, 20); for i:=1 to 20 do begin write(p[i], ' '); end;
readln; end.
_________________ NB: *DELL STUDIO 1555*: 15, 6" širokouhlý displej (with LED, 1366 x 768), Intel Core 2 Duo T6500 (2.1GHz, 800MHz, 2MB), 4GB RAM (800MHz DDR2 Dual Channel), 500GB HDD SATA (5400 rpm), ATI Radeon HD4570 (512MB), 8X DVD+/ -RW, Bluetooth, Wireless, WebCam 1.3, 6 článková 56W, Win Vista HP (32bit)|Linux Ubuntu, šasi Black
PC: no tak predstavte si tu najlepsiu zostavu pred 7 rokmi (r.2002) - - po novom nejaky upgrade si doma urobili viem len ze tam fotrik dal ATI Radeon HD4650 1GB? a win7
MOBIL: Nokia XpressMusic 5310,Nokia 5230 (také šunty zatiaľ)
pʎsɥɐ |
|
Registrovaný: 17.04.08 Prihlásený: 08.08.24 Príspevky: 13275 Témy: 425 | 425 Bydlisko: Myjava |
upravene,link treba dat do code...a co znamena,ze ti to zle triedi?
_________________ PC: MSI B450 GAMING PLUS / AMD Ryzen 5 2600 / SilentiumPC Fera 3 HE1224 / ADATA XPG Spectrix D40 DDR4 2x8GB / Gainward GeForce GTX 1060 Phoenix 6GB / Adata XPG Gammix S11 M.2 SSD 480GB NVMe / Seagate BarraCuda HDD 2TB / WD Green 4TB / WD My Book Essential 3.0 2000GB / WD Elements 2000GB / ASUS BW-16D1HT / Creative Sound Blaster Audigy RX / Corsair CX450M / SilentiumPC Regnum RG4T / Dell P2719H / Microsoft Natural Ergonomic Keyboard 4000 / Logitech G102 Prodigy Gaming Mouse / Microlab SOLO9C / Microlab B77 / SONY WH-1000XM4 / Koss Porta Pro / Microsoft Windows 10 64-bit FPP PC (history): ASUS M4A785TD-V EVO / Athlon II X4 640 / Hynix 8GB (2x4GB) DDR3 1600 MHz / Sapphire HD7750 1GB Ultimate Silent Series / AMD Radeon R3 120GB / Seagate 7200.12 500GB / Samsung SH-S223L / Creative Sound Blaster X-Fi XtremeMusic / Axago PCEU-43R USB3.0 / TP-LINK TG-3269 / Corsair VS450 / 24" BenQ G2420HDBL / Gigabyte GT-U8300 NTB: Huawei MateBook D15 NTB2: Alcatel PLUS 10 LTE NTB3: MSI M670X-091SK / Transcend 2x1GB DDR2 667MHz Phone: Samsung Galaxy S9 Phone2: Samsung Galaxy S20+ Turntable: Tesla NC 470 / Ortofon OM 5E |
|
Registrovaný: 05.06.09 Prihlásený: 23.03.14 Príspevky: 557 Témy: 23 | 23 Bydlisko: near DK |
rozmyslala som ci code alebo quote..sorry
no tam ma to zoradit od najmensieho po najvacsi nie? a select sort roztriedi..ale niekedy posledne cislo je mensie..obcas sa stane..
no a shell sort ten to neviem akym systemom triedi ale uplne na vobec nie tak ako by mal..
_________________ NB: *DELL STUDIO 1555*: 15, 6" širokouhlý displej (with LED, 1366 x 768), Intel Core 2 Duo T6500 (2.1GHz, 800MHz, 2MB), 4GB RAM (800MHz DDR2 Dual Channel), 500GB HDD SATA (5400 rpm), ATI Radeon HD4570 (512MB), 8X DVD+/ -RW, Bluetooth, Wireless, WebCam 1.3, 6 článková 56W, Win Vista HP (32bit)|Linux Ubuntu, šasi Black
PC: no tak predstavte si tu najlepsiu zostavu pred 7 rokmi (r.2002) - - po novom nejaky upgrade si doma urobili viem len ze tam fotrik dal ATI Radeon HD4650 1GB? a win7
MOBIL: Nokia XpressMusic 5310,Nokia 5230 (také šunty zatiaľ)
pʎsɥɐ |
|
Registrovaný: 17.04.08 Prihlásený: 08.08.24 Príspevky: 13275 Témy: 425 | 425 Bydlisko: Myjava |
moment,vyhrabem stare CD z UCM s mojimi ulohami,ako som to mal ja a kuknem to...
ak to teda najdem a mal som aj ja tie iste sorty ako ty
_________________ PC: MSI B450 GAMING PLUS / AMD Ryzen 5 2600 / SilentiumPC Fera 3 HE1224 / ADATA XPG Spectrix D40 DDR4 2x8GB / Gainward GeForce GTX 1060 Phoenix 6GB / Adata XPG Gammix S11 M.2 SSD 480GB NVMe / Seagate BarraCuda HDD 2TB / WD Green 4TB / WD My Book Essential 3.0 2000GB / WD Elements 2000GB / ASUS BW-16D1HT / Creative Sound Blaster Audigy RX / Corsair CX450M / SilentiumPC Regnum RG4T / Dell P2719H / Microsoft Natural Ergonomic Keyboard 4000 / Logitech G102 Prodigy Gaming Mouse / Microlab SOLO9C / Microlab B77 / SONY WH-1000XM4 / Koss Porta Pro / Microsoft Windows 10 64-bit FPP PC (history): ASUS M4A785TD-V EVO / Athlon II X4 640 / Hynix 8GB (2x4GB) DDR3 1600 MHz / Sapphire HD7750 1GB Ultimate Silent Series / AMD Radeon R3 120GB / Seagate 7200.12 500GB / Samsung SH-S223L / Creative Sound Blaster X-Fi XtremeMusic / Axago PCEU-43R USB3.0 / TP-LINK TG-3269 / Corsair VS450 / 24" BenQ G2420HDBL / Gigabyte GT-U8300 NTB: Huawei MateBook D15 NTB2: Alcatel PLUS 10 LTE NTB3: MSI M670X-091SK / Transcend 2x1GB DDR2 667MHz Phone: Samsung Galaxy S9 Phone2: Samsung Galaxy S20+ Turntable: Tesla NC 470 / Ortofon OM 5E |
|
Registrovaný: 05.06.09 Prihlásený: 23.03.14 Príspevky: 557 Témy: 23 | 23 Bydlisko: near DK |
alee.. neches mi poslat tie vsetky srandy z toho cd?
_________________ NB: *DELL STUDIO 1555*: 15, 6" širokouhlý displej (with LED, 1366 x 768), Intel Core 2 Duo T6500 (2.1GHz, 800MHz, 2MB), 4GB RAM (800MHz DDR2 Dual Channel), 500GB HDD SATA (5400 rpm), ATI Radeon HD4570 (512MB), 8X DVD+/ -RW, Bluetooth, Wireless, WebCam 1.3, 6 článková 56W, Win Vista HP (32bit)|Linux Ubuntu, šasi Black
PC: no tak predstavte si tu najlepsiu zostavu pred 7 rokmi (r.2002) - - po novom nejaky upgrade si doma urobili viem len ze tam fotrik dal ATI Radeon HD4650 1GB? a win7
MOBIL: Nokia XpressMusic 5310,Nokia 5230 (také šunty zatiaľ)
pʎsɥɐ |
|
Registrovaný: 25.12.06 Prihlásený: 01.03.13 Príspevky: 239 Témy: 20 | 20 Bydlisko: Krásno n/Ky... | |
Registrovaný: 05.06.09 Prihlásený: 23.03.14 Príspevky: 557 Témy: 23 | 23 Bydlisko: near DK |
tak to je pekne co si poslal dik..len ja by som chcela vediet co je zle na tom mojom... : /
_________________ NB: *DELL STUDIO 1555*: 15, 6" širokouhlý displej (with LED, 1366 x 768), Intel Core 2 Duo T6500 (2.1GHz, 800MHz, 2MB), 4GB RAM (800MHz DDR2 Dual Channel), 500GB HDD SATA (5400 rpm), ATI Radeon HD4570 (512MB), 8X DVD+/ -RW, Bluetooth, Wireless, WebCam 1.3, 6 článková 56W, Win Vista HP (32bit)|Linux Ubuntu, šasi Black
PC: no tak predstavte si tu najlepsiu zostavu pred 7 rokmi (r.2002) - - po novom nejaky upgrade si doma urobili viem len ze tam fotrik dal ATI Radeon HD4650 1GB? a win7
MOBIL: Nokia XpressMusic 5310,Nokia 5230 (také šunty zatiaľ)
pʎsɥɐ |
|
Registrovaný: 17.04.08 Prihlásený: 08.08.24 Príspevky: 13275 Témy: 425 | 425 Bydlisko: Myjava |
klaudia píše: alee.. neches mi poslat tie vsetky srandy z toho cd?
to by nebolo odomna pekne,nemyslis? aj ked to myslis pekne budem ta kontaktovat,no neviem ci budem mat uspech, nasiel som iba bubble sort a quick,no pohladam dalej...
_________________ PC: MSI B450 GAMING PLUS / AMD Ryzen 5 2600 / SilentiumPC Fera 3 HE1224 / ADATA XPG Spectrix D40 DDR4 2x8GB / Gainward GeForce GTX 1060 Phoenix 6GB / Adata XPG Gammix S11 M.2 SSD 480GB NVMe / Seagate BarraCuda HDD 2TB / WD Green 4TB / WD My Book Essential 3.0 2000GB / WD Elements 2000GB / ASUS BW-16D1HT / Creative Sound Blaster Audigy RX / Corsair CX450M / SilentiumPC Regnum RG4T / Dell P2719H / Microsoft Natural Ergonomic Keyboard 4000 / Logitech G102 Prodigy Gaming Mouse / Microlab SOLO9C / Microlab B77 / SONY WH-1000XM4 / Koss Porta Pro / Microsoft Windows 10 64-bit FPP PC (history): ASUS M4A785TD-V EVO / Athlon II X4 640 / Hynix 8GB (2x4GB) DDR3 1600 MHz / Sapphire HD7750 1GB Ultimate Silent Series / AMD Radeon R3 120GB / Seagate 7200.12 500GB / Samsung SH-S223L / Creative Sound Blaster X-Fi XtremeMusic / Axago PCEU-43R USB3.0 / TP-LINK TG-3269 / Corsair VS450 / 24" BenQ G2420HDBL / Gigabyte GT-U8300 NTB: Huawei MateBook D15 NTB2: Alcatel PLUS 10 LTE NTB3: MSI M670X-091SK / Transcend 2x1GB DDR2 667MHz Phone: Samsung Galaxy S9 Phone2: Samsung Galaxy S20+ Turntable: Tesla NC 470 / Ortofon OM 5E |
|
Registrovaný: 05.06.09 Prihlásený: 23.03.14 Príspevky: 557 Témy: 23 | 23 Bydlisko: near DK |
cakam cakam ... a to moje sa neda opravit?
_________________ NB: *DELL STUDIO 1555*: 15, 6" širokouhlý displej (with LED, 1366 x 768), Intel Core 2 Duo T6500 (2.1GHz, 800MHz, 2MB), 4GB RAM (800MHz DDR2 Dual Channel), 500GB HDD SATA (5400 rpm), ATI Radeon HD4570 (512MB), 8X DVD+/ -RW, Bluetooth, Wireless, WebCam 1.3, 6 článková 56W, Win Vista HP (32bit)|Linux Ubuntu, šasi Black
PC: no tak predstavte si tu najlepsiu zostavu pred 7 rokmi (r.2002) - - po novom nejaky upgrade si doma urobili viem len ze tam fotrik dal ATI Radeon HD4650 1GB? a win7
MOBIL: Nokia XpressMusic 5310,Nokia 5230 (také šunty zatiaľ)
pʎsɥɐ |
|
Registrovaný: 19.09.06 Prihlásený: 19.11.24 Príspevky: 749 Témy: 31 | 31 Bydlisko: Ružomberok&... | |
Registrovaný: 05.06.09 Prihlásený: 23.03.14 Príspevky: 557 Témy: 23 | 23 Bydlisko: near DK |
stopa27 píše: http://www.gymrk.iglu.cz/DSA-vyhladavanie_usporaduvanie_2009x.pdftuto je nasa prednaska z datovych struktur a algoritmov, urcite si tam vyberies ten spravny sort - uz ho staci len prepisat do pozadovaneho jazyka
dakujem..mozem sa opytat i,j,h,v,N : integer -> tieto premenne mam ako komentovat?
_________________ NB: *DELL STUDIO 1555*: 15, 6" širokouhlý displej (with LED, 1366 x 768), Intel Core 2 Duo T6500 (2.1GHz, 800MHz, 2MB), 4GB RAM (800MHz DDR2 Dual Channel), 500GB HDD SATA (5400 rpm), ATI Radeon HD4570 (512MB), 8X DVD+/ -RW, Bluetooth, Wireless, WebCam 1.3, 6 článková 56W, Win Vista HP (32bit)|Linux Ubuntu, šasi Black
PC: no tak predstavte si tu najlepsiu zostavu pred 7 rokmi (r.2002) - - po novom nejaky upgrade si doma urobili viem len ze tam fotrik dal ATI Radeon HD4650 1GB? a win7
MOBIL: Nokia XpressMusic 5310,Nokia 5230 (také šunty zatiaľ)
pʎsɥɐ |
|
Registrovaný: 19.09.06 Prihlásený: 19.11.24 Príspevky: 749 Témy: 31 | 31 Bydlisko: Ružomberok&... |
no i,j su cyklove premenne, N je dlzka pola a h,v su premenne pouzite pri vypoctoch
ale to sa bezne ani nekomentuje
//inac ak ti nebude fungovat kod z tych prednasok, nehladaj prilis dlho chybu u seba, prednasky z DSA boli plne chyb, len uz nepametam ako na tom bola tato
|
|
Registrovaný: 05.06.09 Prihlásený: 23.03.14 Príspevky: 557 Témy: 23 | 23 Bydlisko: near DK |
dik...skusim to ale stale nik nevidi chybu v hentom mojom prvom?
_________________ NB: *DELL STUDIO 1555*: 15, 6" širokouhlý displej (with LED, 1366 x 768), Intel Core 2 Duo T6500 (2.1GHz, 800MHz, 2MB), 4GB RAM (800MHz DDR2 Dual Channel), 500GB HDD SATA (5400 rpm), ATI Radeon HD4570 (512MB), 8X DVD+/ -RW, Bluetooth, Wireless, WebCam 1.3, 6 článková 56W, Win Vista HP (32bit)|Linux Ubuntu, šasi Black
PC: no tak predstavte si tu najlepsiu zostavu pred 7 rokmi (r.2002) - - po novom nejaky upgrade si doma urobili viem len ze tam fotrik dal ATI Radeon HD4650 1GB? a win7
MOBIL: Nokia XpressMusic 5310,Nokia 5230 (také šunty zatiaľ)
pʎsɥɐ |
|
Registrovaný: 05.06.09 Prihlásený: 23.03.14 Príspevky: 557 Témy: 23 | 23 Bydlisko: near DK |
no tak skompiluje, vyhodi 2casy select sortu a koniec..wtf?!
Kód: program shellsortAselectsort; uses crt,dos;
procedure ShellSort(var pol: array of integer; c:integer); var i,j,h,v,N : integer; begin N:= length(pol); h:= 1; repeat h:=(3*h)+1; until h > N;
repeat h:=(h div 3); for i:= (h+1) to N do begin v:=pol[i]; j:=i; while ( (j > h) and ( pol[j-h] > v) ) do begin pol[j]:= pol[j - h]; dec(j, h); end; pol[j]:=v; end; until h = 1; end;
{begin if h > 0 then begin if n > h then begin ShellSort(c,n - h,h); if c[n] < c[n - h] then begin aux:= c[n]; i:= n; repeat c[i] := c[i - h]; i := i - h; until (i = h) or (aux > c[i - h]); c[i] := aux; end; end; ShellSort(c,n,h div 3); end; end;}
procedure SelectSort (var pole: array of integer; p: integer); var i,j,min,tmp: integer; begin for i:=0 to (p - 1) do begin min:=i; for j:=(i+1) to (p - 1) do begin if (pole[j] < pole[min]) then min:=j; end; tmp:=pole[i]; pole[i]:=pole[min]; pole[min]:=tmp; end; end;
var pole1: array [0..5000] of integer; pole2: array [0..10000] of integer; pole3: array [0..15000] of integer; p : array [0..50] of integer; i : integer; h,m,s,ss,hod,min,sek,s100: word;
begin clrscr; writeln('Klaudia Martvonova'); writeln('zadanie c.5'); writeln; randomize; textcolor(4); writeln ('SELECTSORT');
for i:= 0 to 5000 do pole1[i]:=random(15000); gettime(h,m,s,ss); SelectSort(pole1,i); gettime(hod,min,sek,s100); if s100>ss then writeln(hod-h,':',min-m,':',sek-s,':',s100-ss) else writeln(hod-h,':',min-m,':',sek-s,':',s100);
for i:= 0 to 10000 do pole2[i]:=random(15000); gettime(h,m,s,ss); SelectSort(pole2,i); gettime(hod,min,sek,s100); if s100>ss then writeln(hod-h,':',min-m,':',sek-s,':',s100-ss) else writeln(hod-h,':',min-m,':',sek-s,':',s100);
for i:= 0 to 15000 do pole3[i]:=random(15000); gettime(h,m,s,ss); SelectSort(pole3,i); gettime(hod,min,sek,s100); if s100>ss then writeln(hod-h,':',min-m,':',sek-s,':',s100-ss) else writeln(hod-h,':',min-m,':',sek-s,':',s100);
textcolor(15); writeln; writeln('SHELLSORT'); gettime(h,m,s,ss); ShellSort(pole1,5000); gettime(hod,min,sek,s100); if s100>ss then writeln(hod-h,':',min-m,':',sek-s,':',s100-ss) else writeln(hod-h,':',min-m,':',sek-s,':',s100); gettime(h,m,s,ss); ShellSort(pole2,10000); gettime(hod,min,sek,s100); if s100>ss then writeln(hod-h,':',min-m,':',sek-s,':',s100-ss) else writeln(hod-h,':',min-m,':',sek-s,':',s100); gettime(h,m,s,ss); ShellSort(pole3,15000); gettime(hod,min,sek,s100); if s100>ss then writeln(hod-h,':',min-m,':',sek-s,':',s100-ss) else writeln(hod-h,':',min-m,':',sek-s,':',s100);
textcolor(2); writeln; writeln('SELECTSORT'); textcolor(9); for i:=1 to 20 do begin p[i]:=random(20); write(p[i], ' '); end; writeln; writeln; textcolor(8); writeln('TRIEDENIE PRVKOV'); textcolor(5); SelectSort(p, 20); for i:=1 to 20 do begin write(p[i], ' '); end;
textcolor(2); writeln; writeln; writeln('SHELLSORT'); textcolor(9); for i:=1 to 20 do begin p[i]:=random(20); write(p[i], ' '); end; writeln; textcolor(8); writeln; writeln('TRIEDENIE PRVKOV'); textcolor(5); ShellSort(p, 20); for i:=1 to 20 do begin write(p[i], ' '); end;
readln; end.
_________________ NB: *DELL STUDIO 1555*: 15, 6" širokouhlý displej (with LED, 1366 x 768), Intel Core 2 Duo T6500 (2.1GHz, 800MHz, 2MB), 4GB RAM (800MHz DDR2 Dual Channel), 500GB HDD SATA (5400 rpm), ATI Radeon HD4570 (512MB), 8X DVD+/ -RW, Bluetooth, Wireless, WebCam 1.3, 6 článková 56W, Win Vista HP (32bit)|Linux Ubuntu, šasi Black
PC: no tak predstavte si tu najlepsiu zostavu pred 7 rokmi (r.2002) - - po novom nejaky upgrade si doma urobili viem len ze tam fotrik dal ATI Radeon HD4650 1GB? a win7
MOBIL: Nokia XpressMusic 5310,Nokia 5230 (také šunty zatiaľ)
pʎsɥɐ |
|
Registrovaný: 19.09.06 Prihlásený: 19.11.24 Príspevky: 749 Témy: 31 | 31 Bydlisko: Ružomberok&... |
exit code 201 znamena chyba rozsahu pola, niekde asi citas/pises za hranice.
//v selectsorte to bude asi, mas tam index od 0, pascal ide myslim od 1
|
|
Registrovaný: 25.12.06 Prihlásený: 01.03.13 Príspevky: 239 Témy: 20 | 20 Bydlisko: Krásno n/Ky... |
len tak na rychlo, je to upravene podla toho fleshu, skus to takto, co to spravi
Kód: procedure SelectSort (var c1: array of integer; p: integer); var i,j,min,tmp: integer; begin for i:=0 to (p - 1) do begin min:=i; for j:=(i+1) to (p - 1) do begin if (c1[j] < c1[min]) then min:=j; end; tmp:=c1[min]; c1[min]:=c1[i]; c1[i]:=tmp; end; end;
|
|
Registrovaný: 05.06.09 Prihlásený: 23.03.14 Príspevky: 557 Témy: 23 | 23 Bydlisko: near DK |
select sort ide v pohode az kym tam neupravim ten shell sort..to nechapem ...lebo ta prva verzia co je uplne hore tak ide aj to aj to .. len v tom shell sorte nieco blbne a nejak zle to triedi... ***
_________________ NB: *DELL STUDIO 1555*: 15, 6" širokouhlý displej (with LED, 1366 x 768), Intel Core 2 Duo T6500 (2.1GHz, 800MHz, 2MB), 4GB RAM (800MHz DDR2 Dual Channel), 500GB HDD SATA (5400 rpm), ATI Radeon HD4570 (512MB), 8X DVD+/ -RW, Bluetooth, Wireless, WebCam 1.3, 6 článková 56W, Win Vista HP (32bit)|Linux Ubuntu, šasi Black
PC: no tak predstavte si tu najlepsiu zostavu pred 7 rokmi (r.2002) - - po novom nejaky upgrade si doma urobili viem len ze tam fotrik dal ATI Radeon HD4650 1GB? a win7
MOBIL: Nokia XpressMusic 5310,Nokia 5230 (také šunty zatiaľ)
pʎsɥɐ |
|
Registrovaný: 19.09.06 Prihlásený: 19.11.24 Príspevky: 749 Témy: 31 | 31 Bydlisko: Ružomberok&... |
chyba rozsahu
length(pole) vratilo 5001 namiesto 20.
skus nahradit N:=length(); za N:=c;
|
|
Registrovaný: 05.06.09 Prihlásený: 23.03.14 Príspevky: 557 Témy: 23 | 23 Bydlisko: near DK |
m@-nX píše: len tak na rychlo, je to upravene podla toho fleshu, skus to takto, co to spravi Kód: procedure SelectSort (var c1: array of integer; p: integer); var i,j,min,tmp: integer; begin for i:=0 to (p - 1) do begin min:=i; for j:=(i+1) to (p - 1) do begin if (c1[j] < c1[min]) then min:=j; end; tmp:=c1[min]; c1[min]:=c1[i]; c1[i]:=tmp; end; end;
DAKUJEM ZA SNAHU..ale..ShellSort potrebujem tam dorobit..
_________________ NB: *DELL STUDIO 1555*: 15, 6" širokouhlý displej (with LED, 1366 x 768), Intel Core 2 Duo T6500 (2.1GHz, 800MHz, 2MB), 4GB RAM (800MHz DDR2 Dual Channel), 500GB HDD SATA (5400 rpm), ATI Radeon HD4570 (512MB), 8X DVD+/ -RW, Bluetooth, Wireless, WebCam 1.3, 6 článková 56W, Win Vista HP (32bit)|Linux Ubuntu, šasi Black
PC: no tak predstavte si tu najlepsiu zostavu pred 7 rokmi (r.2002) - - po novom nejaky upgrade si doma urobili viem len ze tam fotrik dal ATI Radeon HD4650 1GB? a win7
MOBIL: Nokia XpressMusic 5310,Nokia 5230 (také šunty zatiaľ)
pʎsɥɐ |
|
Registrovaný: 19.09.06 Prihlásený: 19.11.24 Príspevky: 749 Témy: 31 | 31 Bydlisko: Ružomberok&... |
ja som vravel o shellsorte
ked to nahradit v tom kode z pdf za to, co som ti napisal, tak to pekne funguje
|
|
Registrovaný: 05.06.09 Prihlásený: 23.03.14 Príspevky: 557 Témy: 23 | 23 Bydlisko: near DK |
stopa27 píše: ja som vravel o shellsorte ked to nahradit v tom kode z pdf za to, co som ti napisal, tak to pekne funguje
no ja som to prepisala a nejde mi to..teda prepisala som len tu proceduru..sak aj som to tu hodila..cely ten zdrojovy kod
_________________ NB: *DELL STUDIO 1555*: 15, 6" širokouhlý displej (with LED, 1366 x 768), Intel Core 2 Duo T6500 (2.1GHz, 800MHz, 2MB), 4GB RAM (800MHz DDR2 Dual Channel), 500GB HDD SATA (5400 rpm), ATI Radeon HD4570 (512MB), 8X DVD+/ -RW, Bluetooth, Wireless, WebCam 1.3, 6 článková 56W, Win Vista HP (32bit)|Linux Ubuntu, šasi Black
PC: no tak predstavte si tu najlepsiu zostavu pred 7 rokmi (r.2002) - - po novom nejaky upgrade si doma urobili viem len ze tam fotrik dal ATI Radeon HD4650 1GB? a win7
MOBIL: Nokia XpressMusic 5310,Nokia 5230 (také šunty zatiaľ)
pʎsɥɐ |
|
Registrovaný: 19.09.06 Prihlásený: 19.11.24 Príspevky: 749 Témy: 31 | 31 Bydlisko: Ružomberok&... |
toto mi funguje (az na drobnost, ze v select sotre sa neberie do uvahy posledny prvok pri triedeni )
Kód: program shellsortAselectsort; uses crt,dos;
procedure ShellSort(var pol: array of integer; c:integer); var i,j,h,v,N : integer; begin N:= c; h:= 1; repeat h:=(3*h)+1; until h > N;
repeat h:=(h div 3); for i:= (h+1) to N do begin v:=pol[i]; j:=i; while ( (j > h) and ( pol[j-h] > v) ) do begin pol[j]:= pol[j - h]; dec(j, h); end; pol[j]:=v; end; until h = 1; end;
{begin if h > 0 then begin if n > h then begin ShellSort(c,n - h,h); if c[n] < c[n - h] then begin aux:= c[n]; i:= n; repeat c[i] := c[i - h]; i := i - h; until (i = h) or (aux > c[i - h]); c[i] := aux; end; end; ShellSort(c,n,h div 3); end; end;}
procedure SelectSort (var pole: array of integer; p: integer); var i,j,min,tmp: integer; begin for i:=0 to (p - 1) do begin min:=i; for j:=(i+1) to (p - 1) do begin if (pole[j] < pole[min]) then min:=j; end; tmp:=pole[i]; pole[i]:=pole[min]; pole[min]:=tmp; end; end;
var pole1: array [0..5000] of integer; pole2: array [0..10000] of integer; pole3: array [0..15000] of integer; p : array [0..50] of integer; i : integer; h,m,s,ss,hod,min,sek,s100: word;
begin clrscr; writeln('Klaudia Martvonova'); writeln('zadanie c.5'); writeln; randomize; textcolor(4); writeln ('SELECTSORT');
for i:= 0 to 5000 do pole1[i]:=random(15000); gettime(h,m,s,ss); SelectSort(pole1,i); gettime(hod,min,sek,s100); if s100>ss then writeln(hod-h,':',min-m,':',sek-s,':',s100-ss) else writeln(hod-h,':',min-m,':',sek-s,':',s100);
for i:= 0 to 10000 do pole2[i]:=random(15000); gettime(h,m,s,ss); SelectSort(pole2,i); gettime(hod,min,sek,s100); if s100>ss then writeln(hod-h,':',min-m,':',sek-s,':',s100-ss) else writeln(hod-h,':',min-m,':',sek-s,':',s100);
for i:= 0 to 15000 do pole3[i]:=random(15000); gettime(h,m,s,ss); SelectSort(pole3,i); gettime(hod,min,sek,s100); if s100>ss then writeln(hod-h,':',min-m,':',sek-s,':',s100-ss) else writeln(hod-h,':',min-m,':',sek-s,':',s100);
textcolor(15); writeln; writeln('SHELLSORT'); gettime(h,m,s,ss); ShellSort(pole1,5000); gettime(hod,min,sek,s100); if s100>ss then writeln(hod-h,':',min-m,':',sek-s,':',s100-ss) else writeln(hod-h,':',min-m,':',sek-s,':',s100); gettime(h,m,s,ss); ShellSort(pole2,10000); gettime(hod,min,sek,s100); if s100>ss then writeln(hod-h,':',min-m,':',sek-s,':',s100-ss) else writeln(hod-h,':',min-m,':',sek-s,':',s100); gettime(h,m,s,ss); ShellSort(pole3,15000); gettime(hod,min,sek,s100); if s100>ss then writeln(hod-h,':',min-m,':',sek-s,':',s100-ss) else writeln(hod-h,':',min-m,':',sek-s,':',s100);
textcolor(2); writeln; writeln('SELECTSORT'); textcolor(9); for i:=1 to 20 do begin p[i]:=random(20); write(p[i], ' '); end; writeln; writeln; textcolor(8); writeln('TRIEDENIE PRVKOV'); textcolor(5); SelectSort(p, 20); for i:=1 to 20 do begin write(p[i], ' '); end;
textcolor(2); writeln; writeln; writeln('SHELLSORT'); textcolor(9); for i:=1 to 20 do begin p[i]:=random(20); write(p[i], ' '); end; writeln; textcolor(8); writeln; writeln('TRIEDENIE PRVKOV'); textcolor(5); ShellSort(p, 20); for i:=1 to 20 do begin write(p[i], ' '); end;
readln; end.
|
|
Registrovaný: 05.06.09 Prihlásený: 23.03.14 Príspevky: 557 Témy: 23 | 23 Bydlisko: near DK |
jaj 3x edit
uz to ide ak niekto bude potrebovat tak napiste SS
_________________ NB: *DELL STUDIO 1555*: 15, 6" širokouhlý displej (with LED, 1366 x 768), Intel Core 2 Duo T6500 (2.1GHz, 800MHz, 2MB), 4GB RAM (800MHz DDR2 Dual Channel), 500GB HDD SATA (5400 rpm), ATI Radeon HD4570 (512MB), 8X DVD+/ -RW, Bluetooth, Wireless, WebCam 1.3, 6 článková 56W, Win Vista HP (32bit)|Linux Ubuntu, šasi Black
PC: no tak predstavte si tu najlepsiu zostavu pred 7 rokmi (r.2002) - - po novom nejaky upgrade si doma urobili viem len ze tam fotrik dal ATI Radeon HD4650 1GB? a win7
MOBIL: Nokia XpressMusic 5310,Nokia 5230 (také šunty zatiaľ)
pʎsɥɐ |
|
Stránka: 1 z 1
| [ Príspevkov: 23 ] | |
|