!!!
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 sequentially and divided into chunks of exactly m bytes.
For each chunk:
Read up to m bytes from the input file.
If fewer than m bytes are available before reaching the end of file (EOF),
pad the remaining bytes with the character '*' (ASCII 42) so that the output chunk still contains exactly m bytes.
Each chunk is written to a new output file.
The output filenames are formed by appending .1, .2, .3, and so on directly after the original filename.
For example, splitting a file named data produces:
data.1 data.2 data.3 ...
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 shiy
testfile0.2 : (50 bytes)
ou kono omoi wo dou shiyou abara no oku wo Zarame
testfile0.3 : (50 bytes)
ga tokete gero ni narisou (Boom!) Doukou bachi h
testfile0.4 : (50 bytes)
iraite obore shinisou Ima kono yo de kimi dake da
testfile0.5 : (50 bytes)
iseikai*******************************************
Sample 2 files
m = 5
input file:
testfile1 :
HelloWorld12345
output files:
testfile1.1 : (5 bytes)
Hello
testfile1.2 : (5 bytes)
World
testfile1.3 : (5 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)
======================================================================== Congra
testfile2.2 : (80 bytes)
tulations! Your Q@K head0 row00~row15 layer is correct! Pattern No. 0 is
testfile2.3 : (80 bytes)
successfully passed ! =========================================================
testfile2.4 : (80 bytes)
===============*****************************************************************
Sample 4 files
m = 13
input file:
testfile3 :
BBBBBBBBBBBBBBBB
output files:
testfile3.1 : (13 bytes)
BBBBBBBBBBBBB
testfile3.2 : (13 bytes)
BBB**********
Sample 5 files
m = 8
input file:
testfile4 :
A A A A
output files:
testfile4.1 : (8 bytes)
A A A
testfile4.2 : (8 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.