Book Image

The Modern C++ Challenger

By : Brent Arnold, Kristian Secor
Book Image

The Modern C++ Challenger

By: Brent Arnold, Kristian Secor

Overview of this book

C++ is one of the most widely-used programming languages and has applications in a variety of fields, such as gaming, GUI programming, and operating systems, to name a few. Through the years, C++ has evolved into one of the top choices for software developers worldwide. You’ll begin your challenge with various math problems, including Armstrong numbers. As you progress through the course, the complexity of the challenges will increase. You’ll write a class template that represents a two-dimensional array container. You’ll also write a program to find files in a directory that match a regular expression. While tackling algorithms and data structures, you’ll create buffers and print histograms. Things will get tougher when you’ll write code to implement a general-purpose parallel algorithm using asynchronous functions. Whether it is creating an EAN-13 barcode generator or encrypting and decrypting files, this course will put your skills to test and in turn teach you several new features of C++.
Table of Contents (10 chapters)
Chapter 6
Design Patterns
Content Locked
Section 4
Level 6 - Problem 3
Write a program that can generate social security numbers for two countries, Northeria and Southeria, that have different but similar formats for the numbers: - In Northeria, the numbers have the format SYYYYMMDDNNNNNC, where S is a digit representing the sex, 9 for females and 7 for males, YYYYMMDD is the birth date, NNNNN is a five-digit random number, unique for a day (meaning that the same number can appear twice for two different dates, but not the same date), and C is a digit picked so that the checksum computed as described later is a multiple of 11. - In Southeria, the numbers have the format SYYYYMMDDNNNNC, where S is a digit representing the sex, 1 for females and 2 for males, YYYYMMDD is the birth date, NNNN is a four-digit random number, unique for a day, and C is a digit picked so that the checksum computed as described below is a multiple of 10. The checksum in both cases is a sum of all the digits, each multiplied by its weight (the position from the most significant digit to the least). For example, the checksum for the Southerian number 12017120134895 is computed as follows: crc = 14*1 + 13*2 + 12*0 + 11*1 + 10*7 + 9*1 + 8*2 + 7*0 + 6*1 + 5*3 + 4*4 + 3*8 + 2*9 + 1*5 = 230 = 23 * 10