Show a loop which prints random numbers (each number newly generated each loop) from 0 to 19 (inclusive). If a number is 10, stop the loop after print
Continue ReadingC++: Magic Squares of Odd Order
A magic square is an square matrix whose numbers (usually integers) consist of consecutive numbers arranged so that the sum of each row and column, a
Continue ReadingC++: Maze Generation
Generate and show a maze, using the simple Depth-first search algorithm. Start at a random cell. Mark the current cell as visited, and get a l
Continue ReadingC++ Full Course
[pt_view id="3a900e2db9"]
Continue ReadingRead/convert an InputStream to a String
If you have java.io.InputStream object, how should you process that object and produce a String? Suppose I have an InputStream that contains te
Continue ReadingC++: Merge Sort
#include <iostream> using namespace std; void merge(int a[], const int low, const int mid, const int high) { // Variables declarati
Continue ReadingC++: Bubble Sort
#include <algorithm> template<typename Iterator> void bubbleSort(Iterator first, Iterator last) { Iterator i, j; for (i = fir
Continue ReadingC++: 24 Game
The 24 Game tests one's mental arithmetic. Write a program that randomly chooses and displays four digits, each from one to nine, with repetitions
Continue ReadingC++: Caesar Cipher
Implement a Caesar cipher, both encoding and decoding. The key is an integer from 1 to 25. This cipher rotates (either towards left or right) the
Continue ReadingC++: Swap Containers
On lines 7–8, we create two std::vectors and initialise them with values. On line 10, we swap the contents of the two std::vectors using the std:
Continue Reading




