For this program reads the first 11 characters

Assignment Help C/C++ Programming
Reference no: EM13165441

E main for this program reads the first 11 characters from input, saving them. It then reads 26 short integers into |vals|, and passes them and the characters to EmbedWatermark, which subtly alters the contents of vals to contain the characters. After EmbedWatermark returns, main checks that no value in |vals| has changed by more than 7. (Note this would be the case if the bottom three bits had been changed, but no other bits.) The main then passes a copy of |vals| to PrintWatermark, which prints out the original characters by extracting them from |vals|, with no other data needed. The point of the exercise is to elegantly pack the bits of the chars into the LSBs of the values, and then unpack them, as a means of learning bitwise operations. But, it also shows how subtle "watermarks" can be embedded in data via small adjustments to its LSBs. Image data, in particular, is suitable for this, and watermarks are sometimes used to identify different copies of an image for copyright purposes. For the files below, nter code for PackChars.c #include #include #define NUM_VALS 26 #define NUM_CHARS 11 #define MAX_DIFF 7 #define BITS_PER_CHAR 7 #define LSBS 3 int main() { short *vals = calloc(NUM_VALS, sizeof(short)); char msg[NUM_CHARS]; int i, diff; short copy[NUM_VALS]; for (i = 0; i < NUM_CHARS; i++) msg[i] = getchar(); for (i = 0; i < NUM_VALS; i++) { scanf("%hd", &vals[i]); copy[i] = vals[i]; } EmbedWatermark(vals, msg); for (i = 0; i < NUM_CHARS; i++) msg[i] = 0; for (i = 0; i < NUM_VALS; i++) { diff = vals[i] - copy[i]; if (diff > MAX_DIFF || diff < -MAX_DIFF) printf("Val %d differs too much\n", i); copy[i] = vals[i]; } PrintWatermark(copy); } Test Cases: Test 1 Input Sample Data -32768 32767 -1 2 3 13345 0 12345 1023 -1022 32766 -32767 42 8192 -2 -3 -4 -1 1 2 3 1 30333 0 1023 32767 -32768 Output Sample Data

Reference no: EM13165441

Questions Cloud

Estimate of the temperature at which this solution : glycerol has a density of and a molecular weight of. If mL are mixed with a kg of water, what is a good estimate of the temperature at which this solution with freeze?
Process cost system to record the costs of processing : HomeStyle Soup Co. uses a process cost system to record the costs of processing soup, which requires the cooking and filling processes. Materials are entered from the cooking process at the beginning of the filling process.
Find the amount of heat transferred from the water : A 486 mL sample of water was cooled from 50.0°C to 10.0°C. Assuming a specific heat of 4.184 J/K g and a density of 1.00 g/mL, find the amount of heat transferred from the water to the surroundings.
What will be the equilibrium concentration of co : what will be the equilibrium concentration of CO.
For this program reads the first 11 characters : E main for this program reads the first 11 characters from input, saving them. It then reads 26 short integers into |vals|, and passes them and the characters to EmbedWatermark, which subtly alters the contents of vals to contain the characters. A..
Calculate and display the number of units of electricity : The manager of PG&E wants a program that calculates a customer's electric bill. He will enter the current and previous meter readings.
Jerry has done some analysis : Jerry has done some analysis about the profit ability of the bicycle shop. If Jerry builds the large bicycle shop, he will earn $60,000 if the market is good, but he will lose $40,000 if the market is bad
Design a 8m x 32 bit memory board : design a 8M x 32 bit memory board. You may use only 256K x 8 bit RAM chips with full parallel addressing.
Create a book class : Create a Book class. In addition to properties of author and isbn, with setters/getters, the Book should override Object's base method "boolean equals(Object)" and have a "boolean validate()" method.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Write a method, to be included in a template unsorted list

Write a metho, to be included in a template unsorted list class, called replace_item, that will receive two xType parameters, one called olditem, the other called newitem.

  To reverse the order of elements on a stack

Write a program in C++ to  reverse the order of elements on a stack S using two additional stacks using one additional stack

  Write function to find whether number is perfect number

Write down the function perfect which determines whether number is perfect number or not. This function must receive number and return true if number is perfect.

  Write c++ program that reads in the average monthly rainfall

Write a C++ program that reads in the average monthly rainfall for a city for each month of the year and then reads in the actual monthly rainfall for each of the previous 12 months

  A linked list of your song structure in cd

The CD object should have a data member that is a linked list of your song structure that you have in CD.  The CD class needs a function that allows it to add a song to the object, that function would then append the song to that instance of the link..

  Least number of comparisons needed

What is the least number of comparisons needed to sort an array of 6 numbers, in the worst case, using any sorting algorithm that sorts with binary comparisons? Explain

  The manager of a football stadium

The manager of a football stadium wants you to write a program that calculates the total ticket sales after each game. There are four types of tickets-box, sideline, premium and general admission. The data is stored in a file, tickets.txt, in the fol..

  Write a loop that fills a vector

Write a loop that fills a vector V with ten  different  random numbers between 1 and 100. output must actually display the random numbers to get credit.

  Create class has three pieces of information as data members

Create a class called Date in C++ that includes three pieces of information as data members: month (type int), day (type int) and yaer (type int).

  Object-oriented systems is the concept of object

At the heart of all object-oriented systems is the concept of an object. Simply stated, an object is a set of related characteristics and their associated actions.

  Implement method to advance any given date by one day

Write C++ implementation of this method. Create and specify any other methods that you require. Include comments which will be helpful to someone who will maintain implementation in the future.

  Write a program that finds the equivalent series

Write a program that finds the equivalent series and parallel resistance for a collection of resistor values. Your program should scan first the number of resistors and then the resistor values. Then compute the equivalent series resistance for all r..

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd