Determine if a string has all the same characters: Difference between revisions
Determine if a string has all the same characters (view source)
Revision as of 02:31, 11 April 2024
, 1 month ago→{{header|S-BASIC}}: revamp output display
(Added S-BASIC example) |
(→{{header|S-BASIC}}: revamp output display) |
||
Line 3,514:
end = result
rem - examine test cases▼
var p = integer▼
▲var str = string
▲var p = integer
report ""
report " "
report "2"
report "333"
report ".55"
▲ print "The test string "; chr(34); str; chr(34); \
report "tttTTT"
▲ " has length ="; len(str)
report "4444 444k"
▲ p = samechars(str)
▲ if p = 0 then
▲ print "The characters are all the same"
▲ else
▲ print "Characters differ at position";p;" ('"; \
▲ mid(str,p,1);"'=";right$(hex$(asc(mid(str,p,1))),2);"h)"
▲ print
▲ end
end
Line 3,538 ⟶ 3,541:
{{out}}
<pre>
Test string
The characters are all the same
Test string
The characters are all the same
Test string
The characters are all the same
Test string
The characters are all the same
Test string
▲Characters differ at position 2 ('5' = 35h)
Test string
▲Characters differ at position 4 ('T' = 54h)
Test string
▲Characters differ at position 5 (' ' = 20h)
</pre>
=={{header|Scala}}==
|