Words containing "the" substring: Difference between revisions

add freebasic
(Created page with "{{Draft task}} ;Task: Using the dictionary   [https://web.archive.org/web/20180611003215/http://www.puzzlers.org/pub/wordlists/unixdict.txt unixdict.txt],   search...")
 
(add freebasic)
Line 6:
 
The length of any word shown should have a length &nbsp; <big>'''>&nbsp; 11</big>.
 
=={{header|FreeBASIC}}==
Reuses some code from [[Odd words#FreeBASIC]]
<lang freebasic>#define NULL 0
 
type node
word as string*32 'enough space to store any word in the dictionary
nxt as node ptr
end type
 
function addword( tail as node ptr, word as string ) as node ptr
'allocates memory for a new node, links the previous tail to it,
'and returns the address of the new node
dim as node ptr newnode = allocate(sizeof(node))
tail->nxt = newnode
newnode->nxt = NULL
newnode->word = word
return newnode
end function
 
function length( word as string ) as uinteger
'necessary replacement for the built-in len function, which in this
'case would always return 32
for i as uinteger = 1 to 32
if asc(mid(word,i,1)) = 0 then return i-1
next i
return 999
end function
 
dim as string word
dim as node ptr tail = allocate( sizeof(node) )
dim as node ptr head = tail, curr = head, currj
tail->nxt = NULL
tail->word = "XXXXHEADER"
 
open "unixdict.txt" for input as #1
while true
line input #1, word
if word = "" then exit while
if length(word)>11 then tail = addword( tail, word )
wend
close #1
 
dim as string tempword
 
while curr->nxt <> NULL
for i as uinteger = 1 to length(curr->word)-3
if mid(curr->word,i,3) = "the" then print curr->word
next i
curr = curr->nxt
wend</lang>
{{out}}
<pre>
authenticate
chemotherapy
chrysanthemum
clothesbrush
clotheshorse
eratosthenes
featherbedding
featherbrain
featherweight
gaithersburg
hydrothermal
lighthearted
mathematician
neurasthenic
nevertheless
northeastern
northernmost
otherworldly
parasympathetic
physiotherapist
physiotherapy
psychotherapeutic
psychotherapist
psychotherapy
radiotherapy
southeastern
southernmost
theoretician
weatherbeaten
weatherproof
weatherstrip
weatherstripping</pre>
 
=={{header|Ring}}==
781

edits