Could you please help me make a bubble sort program in DOS.
In BASIC or any other language rather easy just move the largest item up the array repeatedly.
yeah. i know how to make a bubble sort program in C. I just want it translated in DOS but I don't know the right syntax. If you could give me the source code in DOS i'll be very grateful.
You need a C compiler that makes DOS compatible exe's. Maybe Turbo C. The code can be the same except for headers.
DOS is an Operating System, that is what the OS bit stands for. To make a bubble sort you need a programming language which DOS is not.
I suspect the OP wants a batch routine running from the Command Prompt which some have this mistaken idea is DOS just because it has a prompt similar to DOS.
Stuart
Here's a batch (not DOS, ha ha!) sorter. It's kind of cludgy, but that's batch for ya. I left in the intermediate displays for more graphic demonstration:
::===== begin batch bsort.bat
@echo off & setlocal enabledelayedexpansion
set c=-1
for /f %%a in (unsort) do (
set /a c+=1
set a!c!=%%a
)
echo initial:
call :disp::---------------------
for /L %%a in (%c%,-1,1) do call :xx %%a
echo final:
call :disp
goto :eof:xx
echo level %1
set k=0
:xxx
call :disp
set /a b=k+1echo k: %k% ak:!a%k%! ab:!a%b%!
if !a%k%! gtr !a%b%! (
set h=!a%k%!
set a%k%=!a%b%!
set a%b%=!h!
)
set /a k+=1
echo incremented k: %k% of %1
if %k% lss %1 goto :xxx
goto :eof:disp
for /L %%a in (0,1,%c%) do echo %%a !a%%a!
echo ------
pause
Yes (14) | ![]() | |
No (14) | ![]() | |
I don't know (15) | ![]() |