Update all new Tasks
This commit is contained in:
parent
00a190b0a6
commit
91df62d461
5697 changed files with 93386 additions and 804 deletions
27
Task/String-matching/BASIC/string-matching-1.basic
Normal file
27
Task/String-matching/BASIC/string-matching-1.basic
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
first$ = "qwertyuiop"
|
||||
|
||||
'Determining if the first string starts with second string
|
||||
second$ = "qwerty"
|
||||
IF LEFT$(first$, LEN(second$)) = second$ THEN
|
||||
PRINT "'"; first$; "' starts with '"; second$; "'"
|
||||
ELSE
|
||||
PRINT "'"; first$; "' does not start with '"; second$; "'"
|
||||
END IF
|
||||
|
||||
'Determining if the first string contains the second string at any location
|
||||
'Print the location of the match for part 2
|
||||
second$ = "wert"
|
||||
x = INSTR(first$, second$)
|
||||
IF x THEN
|
||||
PRINT "'"; first$; "' contains '"; second$; "' at position "; x
|
||||
ELSE
|
||||
PRINT "'"; first$; "' does not contain '"; second$; "'"
|
||||
END IF
|
||||
|
||||
' Determining if the first string ends with the second string
|
||||
second$ = "random garbage"
|
||||
IF RIGHT$(first$, LEN(second$)) = second$ THEN
|
||||
PRINT "'"; first$; "' ends with '"; second$; "'"
|
||||
ELSE
|
||||
PRINT "'"; first$; "' does not end with '"; second$; "'"
|
||||
END IF
|
||||
18
Task/String-matching/BASIC/string-matching-2.basic
Normal file
18
Task/String-matching/BASIC/string-matching-2.basic
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
10 A$ = "THIS, THAT, AND THE OTHER THING"
|
||||
20 S$ = "TH"
|
||||
30 DEF FN S(P) = MID$(A$, P, LEN(S$)) = S$
|
||||
40 PRINT A$ : PRINT
|
||||
|
||||
110 S$(1) = "STARTS"
|
||||
120 S$(0) = "DOES NOT START"
|
||||
130 PRINT S$(FN S(1))" WITH "S$ : PRINT
|
||||
|
||||
210 R$ = "" : FOR I = 1 TO LEN(A$) - LEN(S$) : IF FN S(I) THEN R$ = R$ + STR$(I) + " "
|
||||
220 NEXT I
|
||||
230 IF LEN(R$) = 0 THEN PRINT "DOES NOT CONTAIN "S$
|
||||
240 IF LEN(R$) THEN PRINT "CONTAINS "S$" LOCATED AT POSITION "R$
|
||||
250 PRINT
|
||||
|
||||
310 E$(1) = "ENDS"
|
||||
320 E$(0) = "DOES NOT END"
|
||||
330 PRINT E$(FN S(LEN(A$) - LEN(S$) + 1))" WITH "S$
|
||||
Loading…
Add table
Add a link
Reference in a new issue