| # | Problem | Pass Rate (passed user / total user) |
|---|---|---|
| 14843 | File comparison |
|
| 14844 | File splitting |
|
Description
!!!
It is very important to note that the OJ does not support file operations.
Please manually check whether your program’s output matches the five provided test cases.
After you finish writing your code, make sure to upload it to the OJ. I will download the latest submission for grading.
OJ無法支援file用法,請自行檢查給予的五筆測資和你程式的輸出有沒有相同,寫完後請務必上傳到OJ,我會抓最新的上傳下來批改
!!!
This program compares two text files line by line.
Each line contains at most m characters, and the filenames have a maximum length of n.
The program reads two filenames as input, then opens both files and compares their contents one line at a time.
- For every line number where the two files differ, the program outputs:
- The line number.
- If the two files do not contain the same number of lines, the program must output:
-
The filename of the file with more lines.
-
The number of extra remaining lines in that file.
Line numbers start from 0.
Test File Content
Here are the test files. Please copy and paste them into NotePad and save them as files. Make sure the file names match the ones specified by the OJ exactly.
以下為程式所需比較的file原始內容,請複製貼上到記事本中並存檔,檔名必須要和OJ規範一模一樣。
Sample 1 files
fileA_0.txt :
Tralalero Tralala Trippi Troppi Tung Tung Tung Sahur Ballerina Cappuccina Boneca Ambalabu
fileB_0.txt :
Tralalero Tralala Bombardiro Crocodilo Tung Tung Tung Sahur Ballerina Cappuccina Chimpanzini Bananini Lirili Larila Brr Brr Patapim
Sample 2 files
fileA_1.txt :
A B C
fileB_1.txt :
A B
Sample 3 files
fileA_2.txt :
114514 000 1919810
fileB_2.txt :
114514 111
Sample 4 files
fileA_3.txt :
ch4zi Jt2UPKyRzTUanSokhMqdF744cxEyCphSWHHKQciJzPzKJD18 KaRTn22lDdZl2 A4wHMsW4 FHpPZLWBxc8TUVmhjZPyKPZ A4oMIWxxMSaDfpUc
fileB_3.txt :
aWy1b9tGkCH JA2ex F1Dxh1E2O1d7KICEUOdYKgr5SoWGW2IwF6nAfEIbbOT1AGVmAEEHZqeor68gCEXdxkb rQB22Cta7EmzKaPll8DSwM3THjM42w4f0lnEsCsEJc49w yuAi4Sq5KZX
Sample 5 files
fileA_4.txt :
1Li SZjcsBKE0mK1XZO 8sSGxJcG9kA9YfrghmYDKOhV6wb1kGFEyrRgDi sEDUQgPhtxuzttK0dpmQ6k1LbJJ8QCrknPx4KQc0Bzj aAI 1L5N5
fileB_4.txt :
ABqnd5eYuNHFeIWbKHwK vIKg9QTdriqIW9va8ShMoH9VMuCNqKcn6iDI7MkQykL
Input
Two strings, each representing a filename.
Filename length n ≤ 80 characters.
Each line in the file m ≤ 80 characters.
Output
Zero or more integers indicating the line numbers where the two files differ.
If one file contains additional lines after the other ends, output:
<filename> <extra_line_count>
Sample Input Download
Sample Output Download
Tags
Discuss
Description
!!!
It is very important to note that the OJ does not support file operations.
Please manually check whether your program’s output matches the five provided test cases.
After you finish writing your code, make sure to upload it to the OJ. I will download the latest submission for grading.
OJ無法支援file用法,請自行檢查給予的五筆測資和你程式的輸出有沒有相同,寫完後請務必上傳到OJ,我會抓最新的上傳下來批改
!!!
This program splits an input file into multiple smaller files.
The first input line contains the filename of the file to be split. The filename length is n, where 0 < n ≤ 80.
The second input line contains an integer m, representing the size in bytes for each split file, where 0 < m < 1024.
The original file is read and divided sequentially into chunks of m bytes. Each chunk is written to a new output file. The final chunk may contain fewer than m bytes if the original file ends before reaching m bytes — splitting stops at EOF.
The output filenames are formed by appending .1, .2, .3, and so on directly after the original filename. For example, splitting data produces data.1, data.2, etc.
Here are the test files. Please copy and paste them into CodeBlocks and save them as files. Make sure the file names match the ones specified by the OJ exactly.
You can do this by putting the file name in double quotes and selecting “All Files” when saving.
以下為程式所需比較的file原始內容,請複製貼上到Codeblocks中並存檔,檔名必須要和OJ規範一模一樣。
你可以透過將檔名用""括起來,選擇all file儲存
Sample 1 files
m = 50
input file:
testfile0 :
Kenshi Yonezu - IRIS OUT [Chorus] Ittai dou shiyou kono omoi wo dou shiyou abara no oku wo Zarame ga tokete gero ni narisou (Boom!) Doukou bachi hiraite obore shinisou Ima kono yo de kimi dake daiseikai
output files:
testfile0.1 : (50 bytes)
Kenshi Yonezu - IRIS OUT [Chorus] Ittai dou shiyou
testfile0.2 : (50 bytes)
kono omoi wo dou shiyou abara no oku wo Zarame ga
testfile0.3 : (50 bytes)
tokete gero ni narisou (Boom!) Doukou bachi hirai
testfile0.4 : (50 bytes)
te obore shinisou Ima kono yo de kimi dake daiseik
testfile0.5 : (remaining bytes)
ai
Sample 2 files
m = 5
input file:
testfile1 :
HelloWorld12345
output files:
testfile1.1 : (5 bytes)
Hello
testfile1.2 : (5 bytes)
World
testfile1.3 : (remaining bytes)
12345
Sample 3 files
m = 80
input file:
testfile2 :
======================================================================== Congratulations! Your Q@K head0 row00~row15 layer is correct! Pattern No. 0 is successfully passed ! ========================================================================
output files:
testfile2.1 : (80 bytes)
======================================================================== Congrat
testfile2.2 : (80 bytes)
ulations! Your Q@K head0 row00~row15 layer is correct! Pattern No. 0 is su
testfile2.3 : (80 bytes)
ccessfully passed ! ============================================================
testfile2.4 : (remaining bytes)
============
Sample 4 files
m = 13
input file:
testfile3 :
BBBBBBBBBBBBBBBB
output files:
testfile3.1 : (13 bytes)
BBBBBBBBBBBBB
testfile3.2 : (remaining bytes)
BBB
Sample 5 files
m = 5
input file:
testfile4 :
A A A A
output files:
testfile4.1 : (5 bytes)
A A A
testfile4.2 : (remaining bytes)
A
Input
First line: a string representing the filename to be split.
Second line: an integer m, the size in bytes of each output file.
Output
This program does not print any text. Instead, it creates multiple output files based on the split results.
Ensure that the behavior exactly matches the described rules, including file naming and chunk size.