For a study on cyclomatic complexity and methods to detect errors, Fortran and C code were provided by NIST. That code had syntax errors bad enough to not compile in contemporary compilers, so the syntax errors were fixed. Also, function "Mix" that shuffles the cards was not defined in the article; we provide Fisher-Yates Shuffle algorithm for this.
cmake -B build
cmake --build build
Then run the respective programs by
build/f_blackjack
or
build/c_blackjack
For f_blackjack
the command line flag -d
enables debug mode, where you can set the value of the next card.
As noted in the summary, we provided syntax corrections to the original code, which was not usable otherwise
The 1996 NIST 500-235 publication "Structured Testing: A Testing Methodology Using the Cyclomatic Complexity Metric" tries to do a line-by-line conversion from Fortran. We fixed the syntax errors in blackjack.c and use the Fortran implementations of Mix and Hit in the C program.
The
1982 NIST 500-99 publication
"Structured Testing: A Software Testing Methodology Using the Cyclomatic Complexity Metric"
did a legacy FORTRAN implementation that was needlessly verbose and wasn't easily usable from C.
We minimally updated the NIST blackjack code to Fortran 90 syntax, using Fortran 2003 bind(c)
for convenience, as is generally recommended.
The reusable code and main Fortran program are provided here and compatible with any Fortran compiler.