Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

How to write a readit, calcit, writeit program in C++ that: 1. Reads the first target pattern and compares it to each of the candidate

How to write a "readit, calcit, writeit" program in C++ that:

1. Reads the first target pattern and compares it to each of the candidate patterns. As it compares the patterns, it calculates a score that measures their "closeness." For example, if the target pattern is 242234 and the candidate pattern is 342121, the candidate pattern ;would be given a score of 6: score = abs(2 − 3) + abs(4 − 4) + abs(2 − 2) + abs(2 − 1) + abs(3 − 2) + abs(4 − 1) = 6 . Note that the score is the sum of the absolute values of the differences between each pair of digits in the pattern, and is not just the difference between the numbers!

2. Compares each of the three target patterns to all ten of the candidate patterns, and determines which candidate best fits the target.

3. Prints a three-column table to the screen with column headings Target , Candidate , and Score . At the end of the table, the program prints the location of the candidate that was closest to the target.

4. The program continues to compare target patterns until all the targets are tested.

Candidate
Target
111111
242234
342234
231244
222222
132232
231244

333333

342121

444444

243124

341232

132432

Step by Step Solution

3.41 Rating (157 Votes )

There are 3 Steps involved in it

Step: 1

PROGRAM IN C include include include using namespace std int main long target1 long candid... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Matlab An Introduction with Applications

Authors: Amos Gilat

5th edition

1118629868, 978-1118801802, 1118801806, 978-1118629864

More Books

Students also viewed these Programming questions

Question

=+SPREADSHEET / b. Income from operations, Cargo Division, $255,000

Answered: 1 week ago

Question

=+a. What is P(xn11 , x1)?

Answered: 1 week ago

Question

=+c. What is P(xn11 , y1)? What is P(xn11 . yn)?

Answered: 1 week ago