!!!
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
First line: a string representing the filename to be split.
Second line: an integer m, the size in bytes of each output file.
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.