CONTEST ID : 1128 - 2023春-计导课设-9-12班-文件练习

文件操作练习。注意B题的读取不能用struct。
D和谐词汇的题,输入是若干字符串,不以空行结束. 所以 gets(line);    while (line[0]){... gets(line);}就会导致时间超限,代码在等空行,但in数据没有。应改为while(gets(line))。
/*文件练习B题. 读取一个包含7类数据的二进制文件,找到指定部分内容,并正确解释输出。
思路分析:主体框架是读取二进制文件,   while (fread(buffer, buffLen, 1, infile) > 0){...}
    因为二进制文件的记录长度是固定的,所以可以计算每条记录的长度,使用fseek直接定位到指定段;
    所以用fseek的话,实际只需要读一次就可以。
但是这道题的特殊之处在于,一条记录内是顺序包含7种类型数据,是分多次写入,因此带来的麻烦是
虽然每段内容结构相同,但不能用struct进行整块读取。
因为struct的成员之间有内存空隙;除非源文件本身是用struct格式写入才行。
    因此,可以直接定位,但必须分别读取,写出的代码冗长,且容易在变量名和输出格式上出错。
经测试,struct {含7种变量和数组}的长度为200, 但实际7种变量和数组的总长要小一些.
因此,可以直接定位,但必须分别读取,写出的代码冗长,且容易在变量名和输出格式上出错。
一种办法是:按总长度整块读取到字节数组中,然后再逐个定义对应类型的指针,按间接访问就可格式化解释输出。
例: char buffer[LEN];
int i=0; printf("%c\n", buffer[i]); i++;
short * hdPtr=&buffer[i];  printf("%hd\n", *hdPtr); i+=sizeof(short);
*/


SERVER TIME : 2025-09-19 11:59:50
Finished

STATUS : End    OPEN : Private
Start Time : 2023-03-20 20:00:00
End Time : 2023-05-04 23:59:00


Problem ID    User    Language    Result   

RunID User Nick Name Problem ID Result Memory Time Language Code Length Submit Time
1013662022211307奥本Accepted
1068KB
12ms
C939 bytes2023-05-03 17:34:12
1013652022211307奥本Runtime Error
1068KB
8ms
C939 bytes2023-05-03 17:32:47
1013632022211307奥本Runtime Error
1068KB
8ms
C939 bytes2023-05-03 17:29:35
1013622022211307奥本Runtime Error
1068KB
10ms
C932 bytes2023-05-03 17:28:13
1013602022211307奥本Compile Error
0KB
0ms
C932 bytes2023-05-03 17:26:08
1013542022211307奥本Compile Error
0KB
0ms
C932 bytes2023-05-03 17:22:03
1013512022211307奥本Runtime Error
1068KB
10ms
C822 bytes2023-05-03 17:17:40
1013502022211307奥本Runtime Error
1068KB
9ms
C820 bytes2023-05-03 17:13:28
1013492022211307奥本Runtime Error
1068KB
11ms
C822 bytes2023-05-03 17:11:38
1013062022211307奥本*Accepted97993
1068KB
12ms
C1406 bytes2023-05-03 16:26:04
1003022022211307奥本*Accepted65107
1192KB
11ms
C2342 bytes2023-05-02 18:00:38
1003002022211307奥本Runtime Error
1192KB
11ms
C2238 bytes2023-05-02 17:59:39
1002982022211307奥本Runtime Error
1192KB
12ms
C2195 bytes2023-05-02 17:57:56
1002952022211307奥本Runtime Error
1192KB
10ms
C2195 bytes2023-05-02 17:56:19
1002942022211307奥本Compile Error
0KB
0ms
C2203 bytes2023-05-02 17:55:49
1002932022211307奥本*Accepted65107
1192KB
11ms
C2347 bytes2023-05-02 17:50:47
1002902022211307奥本Wrong Answer
1192KB
10ms
C1204 bytes2023-05-02 17:47:20
1002882022211307奥本Wrong Answer
1192KB
10ms
C1204 bytes2023-05-02 17:44:41
1002272022211307奥本*Accepted96373
1196KB
9ms
C1631 bytes2023-05-02 16:54:37
1002172022211307奥本Runtime Error
1196KB
13ms
C1632 bytes2023-05-02 16:47:25
1002142022211307奥本Runtime Error
1196KB
9ms
C1625 bytes2023-05-02 16:44:54
1002122022211307奥本Runtime Error
1196KB
9ms
C1625 bytes2023-05-02 16:43:20
1002082022211307奥本Wrong Answer
1196KB
12ms
C1625 bytes2023-05-02 16:40:37
1002072022211307奥本Wrong Answer
1196KB
8ms
C1625 bytes2023-05-02 16:39:53
1001502022211307奥本Accepted
1200KB
11ms
C2965 bytes2023-05-02 15:59:23
1001422022211307奥本Wrong Answer
1192KB
12ms
C3329 bytes2023-05-02 15:55:57
1001382022211307奥本Wrong Answer
1192KB
12ms
C2126 bytes2023-05-02 15:53:09
1001352022211307奥本Wrong Answer
1192KB
9ms
C2130 bytes2023-05-02 15:52:35
1001252022211307奥本Wrong Answer
1192KB
13ms
C2138 bytes2023-05-02 15:45:26
1001072022211307奥本Wrong Answer
1192KB
10ms
C2134 bytes2023-05-02 15:22:07
957582022211307奥本Wrong Answer
1196KB
19ms
C2020 bytes2023-04-26 11:40:32
957562022211307奥本Wrong Answer
1196KB
21ms
C2020 bytes2023-04-26 11:39:36
957542022211307奥本Wrong Answer
1196KB
21ms
C2018 bytes2023-04-26 11:36:55
933682022211307奥本Wrong Answer
1196KB
22ms
C2018 bytes2023-04-23 21:50:39
933482022211307奥本Wrong Answer
1196KB
19ms
C2016 bytes2023-04-23 21:42:37
933322022211307奥本Wrong Answer
1072KB
19ms
C1901 bytes2023-04-23 21:27:39
933312022211307奥本Wrong Answer
1072KB
19ms
C1857 bytes2023-04-23 21:25:09
933302022211307奥本Compile Error
0KB
0ms
C1856 bytes2023-04-23 21:24:14
933252022211307奥本Wrong Answer
1072KB
21ms
C1829 bytes2023-04-23 21:21:25
933232022211307奥本Runtime Error
1072KB
7ms
C1859 bytes2023-04-23 21:20:18