Talk:Dutch national flag problem: Difference between revisions

Line 46:
 
:::Perhaps. Some effort has been made in a unique way and I did not want to discourage someone new to the site. I remain reluctant and wouldn't mind others chipping in (such as yourself). --[[User:Paddy3118|Paddy3118]] 10:23, 30 August 2012 (UTC)
 
== SOLED IN BATCH/.BAT ==
 
i just solved the problem in batch or .bat, can someone post it in the section for me, i didnt understand all those html things yet.
i also am not sure if this is exactly what it is because in batch you dont have variables witch can contain more than one variable (arrays.
this is the script:
if you copy it and save it as "title".bat and click run it will start. you have to save it as all files and not as ".txt".
everything with REM is explaining, it wont bother in the script.
i hope that this solves the problem correctly and that my English isn't too bad
 
 
REM this part generates variables with the numbers 1-3
REM 1 means red
REM 2 means white
REM 3 means blue
REM variable ball a is the first in row and c is the last in row.
@echo off
cls
goto aset
:aset
cls
set /a R=%random%%% 3 +1
if %r% EQU 1 set a=1
if %r% EQU 2 set a=2
if %r% EQU 3 set a=3
goto bset
:bset
set /a R=%random%%% 3 +1
if %r% EQU 1 set b=1
if %r% EQU 2 set b=2
if %r% EQU 3 set b=3
goto cset
:cset
set /a R=%random%%% 3 +1
if %r% EQU 1 set c=1
if %r% EQU 2 set c=2
if %r% EQU 3 set c=3
goto acheck
REM this part checks if ball 1 is red, ball 2 is white and ball 3 is blue
REM and if they are in row of the dutch flag it will go to the begin again
:acheck
if %a% EQU 1 goto aset
goto bcheck
:bcheck
if %b% EQU 2 goto aset
goto ccheck
:ccheck
if %c% EQU 3 goto aset
goto color1
REM this part gives the numbers colors.
:color1
if %a% EQU 1 set a=red
if %b% EQU 1 set b=red
if %c% EQU 1 set c=red
goto color2
:color2
if %a% EQU 2 set a=white
if %b% EQU 2 set b=white
if %c% EQU 2 set c=white
goto color3
:color3
if %a% EQU 3 set a=blue
if %b% EQU 3 set b=blue
if %c% EQU 3 set c=blue
goto echoert
REM this part shows/echo/prints it, it shows the new dutch flag
REM that is the random generated flag
:echoert
echo the new dutch flag is...
echo %a%
echo %b%
echo %c%
pause
echo and the new dutch flag organised is...
goto posa
REM this part makes sure that variables will be setted when a equals 1/red and when it is red it will,
REM be standing in front of all the white/2 and blue/3 variables/balls/
:posa
if %a% EQU red set posa=1
if %a% EQU white set posa=2
if %a% EQU blue set posa=3
goto posb
:posb
if %b% EQU red set posb=1
if %b% EQU white set posb=2
if %b% EQU blue set posb=3
goto posc
:posc
if %c% EQU red set posc=1
if %c% EQU white set posc=2
if %c% EQU blue set posc=3
goto echopos1
REM this prints/echo/shows all the balls/colors/variables sorted
:echopos1
if %posa% EQU 1 echo %a%
if %posb% EQU 1 echo %b%
if %posc% EQU 1 echo %c%
goto echopos2
:echopos2
if %posa% EQU 2 echo %a%
if %posb% EQU 2 echo %b%
if %posc% EQU 2 echo %c%
goto echopos3
:echopos3
if %posa% EQU 3 echo %a%
if %posb% EQU 3 echo %b%
if %posc% EQU 3 echo %c%
pause
goto aset
REM this resets the script(it will go to top)
Anonymous user