The task is to demonstrate the language's ability to include source code from other files. In C and C++, inclusion of other files is achieved via a
Continue ReadingC++: Align Columns
Given a text file of many lines, where fields within a line are delineated by a single 'dollar' character, write a program that aligns each column of
Continue ReadingC++: Multiple Distinct Objects
Create a sequence (array, list, whatever) consisting of n distinct, initialized items of the same type. n should be determined at runtime. By disti
Continue ReadingWhy is processing a sorted array faster than an unsorted array?
Here is a piece of C++ code that seems very peculiar. For some strange reason, sorting the data miraculously makes the code almost six times faster.
Continue ReadingC++: Anonymous Recursion
While implementing a recursive function, it often happens that we must resort to a separate "helper function" to handle the actual recursion. This
Continue ReadingC++: Compile-Time Calculation
Some programming languages allow calculation of values at compile time. For this task, calculate 10! at compile time. Print the result when the progra
Continue ReadingC++: FASTA Format
In bioinformatics, long character strings are often encoded in a format called FASTA. A FASTA file can contain several strings, each identified by a n
Continue ReadingC++: Increment a Numerical String
This task is about incrementing a numerical string. // standard C++ string stream operators #include <cstdlib> #include <string> #in
Continue ReadingC++: Heap Sort
#include <algorithm> // for std::make_heap, std::sort_heap template <typename Iterator> void heap_sort(Iterator begin, Iterator en
Continue ReadingC++: Hailstone Sequence
The Hailstone sequence of numbers can be generated from a starting positive integer, n by: If n is 1 then the sequence ends. If n is even then
Continue Reading




