Author Topic: Palindrome date (Rosetta Code)  (Read 3032 times)

0 Members and 1 Guest are viewing this topic.

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Palindrome date (Rosetta Code)
« on: April 12, 2021, 07:15:41 pm »
Hi
here a demo for the task search Palindrome Date  http://rosettacode.org/wiki/Palindrome_dates
Code: QB64: [Select]
  1. 'Task
  2. ' Write a program which calculates and shows the next 15 palindromic dates
  3. ' for those countries which express their dates in the   yyyy-mm-dd format
  4. Dim dateTest As String, Mounth As Integer, Day As Integer, Year As Integer, Pal As Integer
  5. dateTest = ""
  6. Mounth = 0
  7. Day = 0
  8. Year = 0
  9. Pal = 0
  10. For Year = 2020 To 2420
  11.     dateTest = LTrim$(Str$(Year))
  12.     For Mounth = 1 To 12
  13.         If Mounth < 10 Then dateTest = dateTest + "0"
  14.         dateTest = dateTest + LTrim$(Str$(Mounth))
  15.         For Day = 1 To 31
  16.             If Mounth = 2 And Day > 28 Then Exit For
  17.             If (Mounth = 4 Or Mounth = 6 Or Mounth = 9 Or Mounth = 11) And Day > 30 Then Exit For
  18.             If Day < 10 Then dateTest = dateTest + "0"
  19.             dateTest = dateTest + LTrim$(Str$(Day))
  20.             'Print dateTest: Sleep
  21.             For Pal = 1 To 4
  22.                 If Mid$(dateTest, Pal, 1) <> Mid$(dateTest, 9 - Pal, 1) Then Exit For
  23.             Next
  24.             If Pal = 5 Then Print dateTest
  25.             dateTest = Left$(dateTest, 6)
  26.         Next
  27.         dateTest = Left$(dateTest, 4)
  28.     Next
  29.     dateTest = ""
  30.  

copy paste and run to take a look
« Last Edit: April 12, 2021, 07:27:10 pm by TempodiBasic »
Programming isn't difficult, only it's  consuming time and coffee