Statistics: Posted by bongomeno — Thu Jan 26, 2023 11:46 pm
Statistics: Posted by bongomeno — Sun Jan 08, 2023 7:42 am
Statistics: Posted by bongomeno — Sat Jan 07, 2023 1:52 am
Code:
rem periodic table lookup examplerem uses carry command to perform modulusrem compile with FTCBASICdefine e = 0, i = 0, m = 0, r = 0, c = 0, q = 0dim a[1, 2, 5, 13, 57, 72, 89, 104]dim b[-1, 15, 25, 35, 72, 21, 58, 7]doclsprint "Periodic Table Lookup"crlfprint "0 to continue or 1 to quit: " \input qclsif q = 0 thengosub displaytablegosub searchtablecrlfprint "Press any key to continue..."pauseendifloop q <> 1endsub searchtableprint "Atomic number: " \input elet i = 8dolet i = i - 1loop @a[i] > elet m = e + @b[i]let r = ( m / 18 ) + 1carry clet c = c + 1cursor 19,20print "Period: " \print r \print " Group: " \print c \crlfreturnsub displaytableprint " 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18"crlfprint " 1 H He"crlfprint " 2 Li Be B C N O F Ne"crlfprint " 3 Na Mg Al Si P S Cl Ar"crlfprint " 4 K Ca Sc Ti V Cr Mn Fe Co Ni Cu Zn Ga Ge As Se Br Kr"crlfprint " 5 Rb Sr Y Zr Nb Mo Tc Ru Rh Pd Ag Cd In Sn Sb Te I Xe"crlfprint " 6 Cs Ba * Hf Ta W Re Os Ir Pt Au Hg Tl Pb Bi Po At Rn"crlfprint " 7 Fr Ra ** Rf Db Sg Bh Hs Mt Ds Rg Cn Nh Fl Mc Lv Ts Og"crlfprint " 8 Lantanoidi* La Ce Pr Nd Pm Sm Eu Gd Tb Dy Ho Er Tm Yb Lu"crlfprint " 9 Aktinoidi** Ac Th Pa U Np Pu Am Cm Bk Cf Es Fm Md No Lr"crlfreturn
Code:
rem Nim game examplerem compile with FTCBASICdefine tokens = 12, take = 0gosub introdoprint "There are " \print tokens \print " tokens remaining."crlfprint "How many would you like to take? " \input takeif take > 3 or take < 1 thenprint "You must take between 1 to 3 tokens."endifif tokens - take < 0 thenprint "You cannot take that many."endifif take <= 3 and take >= 1 and tokens - take >= 0 thenlet tokens = tokens - takeif tokens = 0 thenbellprint "Congratulations. You got the last token."pauseendendiflet take = 4 - takeif tokens >= 15 thenlet take = 3endifif tokens <= 3 thenlet take = tokensendifprint "I will take " \print take \print " of the tokens."let tokens = tokens - takeif tokens = 0 thenprint "I got the last token. I win. Better luck next time."pauseendendifendifloopsub introclsprint "NIM game"crlfprint "Press any key to play..."clsreturn
Code:
rem bubble sort benchmark examplerem compile with FTCBASICuse time.incuse random.incdefine const size = 32000dim list[size]define sorting = 0, index = 0, elements = 0define timestamp = 0, sorttime = 0define temp1 = 0, temp2 = 0clsprint "Bubble sort benchmark test"doprint "How many elements to generate and sort (max " \print size \print ")? " \input elementsloop elements > sizegosub fillgosub sortprint "done!"print "sort time: " \print sorttimeprint "Press any key to view sorted data..."pausegosub outputpauseendsub fillprint "filling..."0 indexdogosub generaterandlet @list[index] = rand+1 indexloop index < elementsreturnsub sortprint "sorting..."gosub systemtimelet timestamp = loworderdo0 sorting0 indexdolet temp1 = index + 1if @list[index] > @list[temp1] thenlet temp2 = @list[index]let @list[index] = @list[temp1]let @list[temp1] = temp2let sorting = 1endif+1 indexloop index < elements - 1loop sorting = 1gosub systemtimelet sorttime = ( loworder - timestamp ) / 18returnsub outputprint "printing..."0 indexdoprint @list[index]+1 indexloop index < elementsreturn
Statistics: Posted by bongomeno — Fri Jan 06, 2023 1:02 am