Palindrome dates: Difference between revisions
m
→{{header|BASIC}}
m (→{{header|RPL}}: Layout) |
|||
Line 561:
=={{header|BASIC}}==
{{works with|QBasic}}▼
==={{header|BASIC256}}===▼
{{trans|FreeBASIC}}▼
dateTest = ""▼
mes = 0 : dia = 0 : anno = 0 : Pal = 0▼
total = 0▼
print "Siguientes 15 fechas palindrómicas al 2020-02-02:"▼
for anno = 2021 to 9999▼
dateTest = ltrim(string(anno))▼
for mes = 1 to 12▼
if mes < 10 then dateTest = dateTest + "0"▼
dateTest = dateTest + ltrim(string(mes))▼
for dia = 1 to 31▼
if mes = 2 and dia > 28 then exit for▼
if (mes = 4 or mes = 6 or mes = 9 or mes = 11) and dia > 30 then exit for▼
if dia < 10 then dateTest = dateTest + "0"▼
dateTest = dateTest + ltrim(string(dia))▼
for Pal = 1 to 4▼
if mid(dateTest, Pal, 1) <> mid(dateTest, 9 - Pal, 1) then exit for▼
next Pal▼
if Pal = 5 then▼
total += 1▼
if total <= 15 then print left(dateTest,4);"-";mid(dateTest,5,2);"-";right(dateTest,2)▼
end if▼
if total > 15 then exit for : exit for : exit for▼
dateTest = left(dateTest, 6)▼
next dia▼
dateTest = left(dateTest, 4)▼
next mes▼
dateTest = ""▼
next anno▼
end▼
</syntaxhighlight>▼
{{out}}▼
<pre>▼
Igual que la entrada de FreeBASIC.▼
</pre>▼
==={{header|QBasic}}===
▲{{works with|QBasic|1.1}}
{{works with|QuickBasic|4.5}}
{{trans|FreeBASIC}}
<syntaxhighlight lang="basic">
Line 595 ⟶ 636:
NEXT anno
END
▲</syntaxhighlight>
▲{{out}}
▲<pre>
▲Igual que la entrada de FreeBASIC.
▲</pre>
▲==={{header|BASIC256}}===
▲{{trans|FreeBASIC}}
▲<syntaxhighlight lang="lb">
▲dateTest = ""
▲mes = 0 : dia = 0 : anno = 0 : Pal = 0
▲total = 0
▲print "Siguientes 15 fechas palindrómicas al 2020-02-02:"
▲for anno = 2021 to 9999
▲ dateTest = ltrim(string(anno))
▲ for mes = 1 to 12
▲ if mes < 10 then dateTest = dateTest + "0"
▲ dateTest = dateTest + ltrim(string(mes))
▲ for dia = 1 to 31
▲ if mes = 2 and dia > 28 then exit for
▲ if (mes = 4 or mes = 6 or mes = 9 or mes = 11) and dia > 30 then exit for
▲ if dia < 10 then dateTest = dateTest + "0"
▲ dateTest = dateTest + ltrim(string(dia))
▲ for Pal = 1 to 4
▲ if mid(dateTest, Pal, 1) <> mid(dateTest, 9 - Pal, 1) then exit for
▲ next Pal
▲ if Pal = 5 then
▲ total += 1
▲ if total <= 15 then print left(dateTest,4);"-";mid(dateTest,5,2);"-";right(dateTest,2)
▲ end if
▲ if total > 15 then exit for : exit for : exit for
▲ dateTest = left(dateTest, 6)
▲ next dia
▲ dateTest = left(dateTest, 4)
▲ next mes
▲ dateTest = ""
▲next anno
▲end
</syntaxhighlight>
{{out}}
|