Question: with the c++ language please. thank you. Problem / Exercise The Hamming distance between two equal length bit strings is the number of positions where

 with the c++ language please. thank you. Problem / Exercise TheHamming distance between two equal length bit strings is the number of

with the c++ language please. thank you.

Problem / Exercise The Hamming distance between two equal length bit strings is the number of positions where the bits do not match. We can calculate the Hamming distance between two non-negative integers by converting them to their unsigned binary (bit string) representation and counting the number of bit positions that do not match. If the two bit strings are not of the same length, then we can add leading zeros to the shorter bit string to make it the same length as the larger bit string. Adding leading zeros to an unsigned bit string does not change their value (e.g. 101 = 0101 = 00101 = 000101). Think about how you would solve this problem with a C++ program, and write a general algorithm on paper and pencil before you write any source code. You may assume the user of your program will input, via command line arguments, two non-negative integers as shown in the Examples section. Consider the following questions and read over the Examples section to get an idea on how your program should work. How do you get command line arguments in C++? How do you convert command line arguments to integers? Hint: Look up the string class in C++11 and its many useful functions. How do you convert a non-negative integer to its bit string (binary)? How do you add leading zeros if the bit strings are not equal? How do you compute the Hamming distance between two equal length bit strings? Examples Your C++ source code should be in a file called labo1.cpp, and it should be compiled into an executable called labo1.out. Your C++ program must look exactly like the examples below when run on the command line on odin, it must compile correctly, and it must run correctly with any valid sequence of inputs. You may assume that the command line arguments for the integers will always be non-negative. However, you may not assume that the integer inputs will be in order. Each example is a separate execution of a correct program for this assignment. 1. ./lab01.out 5 8 0101 is the bit string for 5 1000 is the bit string for 8 3 is the Hamming distance between the bit strings 2. ./lab01.out 1730 30 11011000010 is the bit string for 1730 00000011110 is the bit string for 30 7 is the Hamming distance between the bit strings 3. ./lab01.out 15 0 1111 is the bit string for 15 0000 is the bit string for 0 4 is the Hamming distance between the bit strings 4. ./lab01.out 28 66 0011100 is the bit string for 28 1000010 is the bit string for 66 5 is the Hamming distance between the bit strings 5. ./lab01.out 66 28 1000010 is the bit string for 66 0011100 is the bit string for 28 5 is the Hamming distance between the bit strings 6. ./lab01.out 31 62 011111 is the bit string for 31 111110 is the bit string for 62 2 is the Hamming distance between the bit strings 7. ./lab01.out 13 13 1101 is the bit string for 13 1101 is the bit string for 13 O is the Hamming distance between the bit strings Code Description For this lab, you will need to write a main function that processes command line arguments. Do not prompt the user for input. Here's the main function's signature. int main(int argc, char * argv[]) The main function, the entry-point to your program, should process two non-negative integers inputted via the command line on odin. This function should call other functions to complete the program as shown in the Examples

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!