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 21:56:47
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
8089320222113162022211316Accepted
1192KB
12ms
C2396 bytes2023-04-03 22:05:13
8086320222113162022211316Wrong Answer
1192KB
14ms
C2435 bytes2023-04-03 21:56:57
8085620222113162022211316Accepted
1192KB
11ms
C1671 bytes2023-04-03 21:53:34
8084420222113162022211316Compile Error
0KB
0ms
C1750 bytes2023-04-03 21:49:55
8083920222113162022211316Compile Error
0KB
0ms
C1743 bytes2023-04-03 21:48:55
8083620222113162022211316Compile Error
0KB
0ms
C1744 bytes2023-04-03 21:48:03
8083420222113162022211316Compile Error
0KB
0ms
C1743 bytes2023-04-03 21:47:42
8082920222113162022211316*Accepted64826
1192KB
12ms
C1532 bytes2023-04-03 21:43:14
8082320222113162022211316*Accepted64826
1192KB
12ms
C2572 bytes2023-04-03 21:38:22
8082120222113162022211316Wrong Answer
1196KB
11ms
C1380 bytes2023-04-03 21:36:35
8081820222113162022211316Wrong Answer
1196KB
10ms
C1380 bytes2023-04-03 21:35:57
8081720222113162022211316Compile Error
0KB
0ms
C1377 bytes2023-04-03 21:35:38
8081420222113162022211316Wrong Answer
1196KB
12ms
C1870 bytes2023-04-03 21:35:12
8079320222113162022211316Wrong Answer
1196KB
10ms
C1884 bytes2023-04-03 21:25:21
8076720222113162022211316Wrong Answer
1196KB
10ms
C1733 bytes2023-04-03 21:14:30
8073420222113162022211316Runtime Error
1196KB
9ms
C1642 bytes2023-04-03 20:58:14
8071320222113162022211316Runtime Error
1196KB
10ms
C1574 bytes2023-04-03 20:51:04
8070720222113162022211316Runtime Error
1196KB
12ms
C1236 bytes2023-04-03 20:45:52
8070320222113162022211316Compile Error
0KB
0ms
C1237 bytes2023-04-03 20:45:21
8068820222113162022211316Runtime Error
1196KB
11ms
C1298 bytes2023-04-03 20:34:57
8068720222113162022211316Compile Error
0KB
0ms
C1544 bytes2023-04-03 20:34:06
8065520222113162022211316Runtime Error
1196KB
10ms
C1453 bytes2023-04-03 20:16:23
8065220222113162022211316Accepted
1072KB
12ms
C1418 bytes2023-04-03 20:14:30
8065020222113162022211316Presentation Error
1072KB
10ms
C1441 bytes2023-04-03 20:13:40
8061120222113162022211316Wrong Answer
1072KB
13ms
C1475 bytes2023-04-03 19:47:31
7351920222113162022211316*Accepted65033
1072KB
13ms
C1865 bytes2023-03-29 21:30:20
7351820222113162022211316Presentation Error
1072KB
14ms
C1944 bytes2023-03-29 21:29:25
7347120222113162022211316Runtime Error
1068KB
10ms
C1603 bytes2023-03-29 21:13:13
7343820222113162022211316Wrong Answer
1068KB
12ms
C1577 bytes2023-03-29 21:02:27
7338620222113162022211316*Accepted65033
1072KB
13ms
C1987 bytes2023-03-29 20:47:45
7338320222113162022211316Wrong Answer
1192KB
13ms
C1408 bytes2023-03-29 20:46:59
7298920222113162022211316Accepted
1196KB
12ms
C1454 bytes2023-03-29 17:53:34
7297720222113162022211316Wrong Answer
1196KB
11ms
C1423 bytes2023-03-29 17:45:05
7285420222113162022211316*Accepted64826
1192KB
9ms
C1707 bytes2023-03-29 16:38:43
7283720222113162022211316Runtime Error
1196KB
10ms
C1455 bytes2023-03-29 16:32:29
7053120222113162022211316Wrong Answer
1192KB
14ms
C2435 bytes2023-03-27 18:10:52
7051520222113162022211316Wrong Answer
1192KB
15ms
C2386 bytes2023-03-27 17:52:51
7051220222113162022211316Wrong Answer
1192KB
15ms
C2416 bytes2023-03-27 17:52:13
7044020222113162022211316Wrong Answer
1192KB
16ms
C2592 bytes2023-03-27 16:19:20
7043920222113162022211316Wrong Answer
1192KB
6ms
C2590 bytes2023-03-27 16:18:50
7043720222113162022211316Wrong Answer
1192KB
15ms
C2582 bytes2023-03-27 16:18:08
7043520222113162022211316Wrong Answer
1192KB
15ms
C2478 bytes2023-03-27 16:14:56
7043320222113162022211316Wrong Answer
1192KB
14ms
C2478 bytes2023-03-27 16:14:26
7042920222113162022211316*Accepted64996
1192KB
20ms
C4099 bytes2023-03-27 16:10:47
7042820222113162022211316Wrong Answer
1192KB
14ms
C2303 bytes2023-03-27 16:09:40
7042520222113162022211316Wrong Answer
1192KB
6ms
C2297 bytes2023-03-27 16:08:55
7037920222113162022211316Wrong Answer
1192KB
17ms
C1900 bytes2023-03-27 15:43:07
7037720222113162022211316Runtime Error
1192KB
5ms
C1900 bytes2023-03-27 15:41:17