How to resolve the algorithm Last Friday of each month step by step in the PureBasic programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Last Friday of each month step by step in the PureBasic programming language
Table of Contents
Problem Statement
Write a program or a script that returns the date of the last Fridays of each month of a given year. The year may be given through any simple input method in your language (command line, std in, etc).
Example of an expected output:
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Last Friday of each month step by step in the PureBasic programming language
Source code in the purebasic programming language
Procedure LastFridayOfEachMonth(yyyy.i,List lfem.i())
Define dv.i=ParseDate("%yyyy",Str(yyyy)), mv.i=1
NewList d.i()
For d=1 To 365
dv=AddDate(dv,#PB_Date_Day,1)
If DayOfWeek(dv)=5
AddElement(d()) : d()=dv
EndIf
Next
dv=0
For mv=1 To 12
ForEach d()
If dv<d() And Month(d())=mv
dv=d()
EndIf
Next
AddElement(lfem()) : lfem()=dv
Next
EndProcedure
NewList lf.i()
Define y.i
OpenConsole("Last Friday of each month")
Print("Input Year [ 1971 < y < 2038 ]: ")
y=Val(Input())
If y>1971 And y<2038
PrintN("Last Friday of each month...")
LastFridayOfEachMonth(y,lf())
ForEach lf()
PrintN(FormatDate("%dd.%mm.%yyyy",lf()))
Next
EndIf
Print("...End")
Input()
You may also check:How to resolve the algorithm Mayan numerals step by step in the PureBasic programming language
You may also check:How to resolve the algorithm Ordered partitions step by step in the 11l programming language
You may also check:How to resolve the algorithm Self-describing numbers step by step in the C programming language
You may also check:How to resolve the algorithm Multiplication tables step by step in the Maxima programming language
You may also check:How to resolve the algorithm Binary digits step by step in the 360 Assembly programming language