Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Given 2 files that contain integer data, the goal is to write a C++ program that detects if the files are identical. For example, suppose

Given 2 files that contain integer data, the goal is to write a C++ program that detects if the files are identical. For example, suppose we have two input files data1.txt and

data2.txt with the following data:

17 0

22 22

0 9

15 15

0 17

8 0

Are these files the same? Given the names of two files, your program should input the data into two separate arrays, sort each one, and then output the data side-by-

side followed by a summary. Given the files above:

0,0

0,0

8,9

15,15

17,17

22,22

# of lines: 6

Similarity: 83.3333%

Identical? NO

As you can see from the side-by-side output, the files differ by one pair of values --- data1.txt contains an 8 while data2.txt contains a 9, so one pair (8,9) differs. Since 5 out of 6 pairs are the same, the similarity is 83.3333%. Suppose we have a third input file data3.txt that contains the following data:

15

22

8

0

0

17

When we run the program and specify data1.txt and data3.txt, we get this output:

0,0

0,0

8,8

15,15

17,17

22,22

# of lines: 6

Similarity: 100%

Identical? YES

These files are identical since they contain the same data --- every pair is the same after sorting. Your program should input two filenames to start, and then perform the required computation and output. Assume the files are the same size, i.e. contain the same # of integers; assume at most 500 integers per file.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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

Conceptual Database Design An Entity Relationship Approach

Authors: Carol Batini, Stefano Ceri, Shamkant B. Navathe

1st Edition

0805302441, 978-0805302448

More Books

Students also viewed these Databases questions