Reads(by ifstream infile ) the first target pattern and compares it to each of t
ID: 3592037 • Letter: R
Question
Reads(by ifstream infile) 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.
Candidate
Target
111111
242234
342234
231244
222222
132232
231244
333333
342121
444444
243124
341232
132432
Candidate
Target
111111
242234
342234
231244
222222
132232
231244
333333
342121
444444
243124
341232
132432
Explanation / Answer
Reads(by ifstream infile) 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.
Reads(by ifstream infile) 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.
Reads(by ifstream infile) 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.
Reads(by ifstream infile) 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.
Reads(by ifstream infile) 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.
Reads(by ifstream infile) 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.
Reads(by ifstream infile) 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.
Reads(by ifstream infile) 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.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.