14834 - Binary file comparison   

Description

Write a program to compare two binary files.
The comparison method is to compare one byte at a time and list all the places where they differ.
The input consists of two lines, each containing the filename of one file. The maximum filename length is n.
The output should be the positions (offsets) where the two files differ.
If the two files are of different sizes, you must first output the name of the larger file, then output the extra bytes.

Parameter specification: 0 < n ≤ 80

Input

Consists of two lines, each containing the filename of one file.

The maximum filename length is n.

Ex. leap-year.c
leap-year-mod.c

leap-year.c

#include <stdio.h>
main()
{
    int year;
    int k;
    scanf("%d", &year);
    k = (year % 400 == 0) || ((year % 4 == 0) && (year % 100 != 0));
    printf("%d\n", k);
}

leap-year-mod.c

%include <stdio.h>
maim()
{
    int year;
    int k;
    scanf("%d", &year);
    k = (year % 500 == 0) || ((year % 4 == 0) && (year % 100 != 0));
    pritnf("%d\n", k);
}

Output

The positions (offsets) where the two files differ.

Ex. 0
23
91
156
157
leap-year-mod.c 15

Sample Input  Download

Sample Output  Download




Discuss