pangfengliu / programmingtasks

programming tasks from my courses
68 stars 17 forks source link

Compare Two Files #108

Open sinmaplewing opened 10 years ago

sinmaplewing commented 10 years ago

Task Description

Write a program to compare two files. Your program must compare two files A and B in a line by line or a byte-by-byte manner according to the first command line option. A ‘-byte’ option tells your program to compare two file byte by byte in binary mode, and a ‘-line’ option tells your program to compare two file line by line in text mode. The names of A and B are given as the second and the third command line option.

The constraints on the parameters are as follow.

Note that C has short circuit evaluation. That is, if there is an expression A && B, and we evaluate A to be true, we will then evaluate B. However, if we evaluate A to be false, we will NOT evaluate B since the answer is definitively false. The implication is that if you use A && B as a condition to for continuing the reading process of reading two files, you must realize that if A fails B will not be executed.

Input

All input are given as command line options.

Output

We need to output where these two files are different.

a.exe -line file1 file2

Sample output

Lines 1 differ File file2 has 1 lines remaining

Test Data

You can download the test data (which JudgeGirl uses) from here.

tzuhsien commented 9 years ago

沒有檔案

exe1023 commented 9 years ago

可以重新上傳檔案嗎?