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 program to crypt its input accordingly

Write a program to crypt its input according to a specified transformation scheme

  After the array is created and loaded

After the array is created and loaded, the problem is then to sort the array and print out the contents of the sorted array. Please use a separate function for the sort routine and also a separate function for the print out of the array.

  Write a program code to compute and build a table of reynold

Write a program code to compute and build a table of Reynolds numbers at flow velocities varying from 100 to 1000 ft/sec (at increments of 100)

  Write a program that takes a positive integer

Write a program that takes a positive integer from the user and prints the rightmost digit of that integer. This is a sample output: Enter an integer: 1247

  Write program which inputs number of winning coupons

Write a program which inputs number of coupons you win and outputs how many candy bars and gumballs you can get if you spend all off your coupons on candy bars first and remaining coupons on gumballs in c++.

  Perform operations on arrays

Perform operations on arrays execute tests and repetitions

  Reads in a list of integers

Write a program in C++ that reads in a list of integers into and array with base type int. Provide the facility to either read this array from the keyboard or from a file, at the user's option. If the user chooses file input, the program should reque..

  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

  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).

  Program to check compatibity for matrix multiplication

Write down program in C++ for matrix multiplication. Program must accept dimension of both matrices to be multiplied and check for compatibity.

  Display the array, the average and the number of days above

Write a program that stores the daily temperatures for the month of April in an array name dailytemp. Calculate the average temperature for the month and the count the number of days that the daily temperature was above the average.

  C program to randomly generate more than ten ip address

Write C or C++ program which Randomly generates more than 10 IP addresses written in decimal format and write results in text file (e.g. Dec_IPAddresses.txt)

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