Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
27
Task/Rep-string/Yabasic/rep-string.basic
Normal file
27
Task/Rep-string/Yabasic/rep-string.basic
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
data "1001110011", "1110111011", "0010010010", "1010101010", "1111111111", "0100101101", "0100100", "101", "11", "00", "1", ""
|
||||
|
||||
sub rep$(c$, n)
|
||||
local r$, i
|
||||
|
||||
for i = 1 to n
|
||||
r$ = r$ + c$
|
||||
next
|
||||
return r$
|
||||
end sub
|
||||
|
||||
do
|
||||
read p$ : if p$ = "" break
|
||||
b$ = "" : l = len(p$) : m = int(l / 2)
|
||||
|
||||
for i = m to 1 step -1
|
||||
t$ = left$(p$, i)
|
||||
s$ = rep$(t$, l / i + 1)
|
||||
if p$ = left$(s$, l) b$ = t$ : break
|
||||
next
|
||||
|
||||
if b$ = "" then
|
||||
print p$, " is not a repeated string"
|
||||
else
|
||||
print p$, " is composed of ", b$, " repeated"
|
||||
end if
|
||||
loop
|
||||
Loading…
Add table
Add a link
Reference in a new issue