CONTEST ID : 1134 - 2023春-计导课设-转专业-文件练习

文件操作练习。注意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 10:47:38
Finished

STATUS : End    OPEN : Private
Start Time : 2023-03-24 12: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
1018762022212458谭超Accepted
1068KB
14ms
C1047 bytes2023-05-04 13:46:56
1018742022212458谭超Wrong Answer
1068KB
11ms
C1843 bytes2023-05-04 13:43:19
1018732022212458谭超Wrong Answer
1192KB
11ms
C1398 bytes2023-05-04 13:38:13
1018712022212458谭超Compile Error
0KB
0ms
C2087 bytes2023-05-04 13:35:28
1018702022212458谭超Compile Error
0KB
0ms
C2009 bytes2023-05-04 13:32:49
1018692022212458谭超Wrong Answer
1068KB
11ms
C2035 bytes2023-05-04 13:21:44
1018682022212458谭超Accepted
1204KB
10ms
C1678 bytes2023-05-04 13:14:19
1018672022212458谭超Accepted
1204KB
11ms
C1682 bytes2023-05-04 13:13:24
1018662022212458谭超*Accepted85148
1204KB
10ms
C1657 bytes2023-05-04 13:10:35
1014172022212458谭超Compile Error
0KB
0ms
C1099 bytes2023-05-03 18:33:25
1014032022212458谭超Wrong Answer
1196KB
10ms
C1033 bytes2023-05-03 18:16:49
1013992022212458谭超Wrong Answer
1196KB
10ms
C1033 bytes2023-05-03 18:11:01
1013952022212458谭超Compile Error
0KB
0ms
C1027 bytes2023-05-03 18:06:02
1013912022212458谭超Compile Error
0KB
0ms
C1040 bytes2023-05-03 18:02:13
1013902022212458谭超Compile Error
0KB
0ms
C1030 bytes2023-05-03 18:01:26
1013882022212458谭超Compile Error
0KB
0ms
C1035 bytes2023-05-03 17:59:18
1013842022212458谭超Compile Error
0KB
0ms
C1039 bytes2023-05-03 17:53:59
1012202022212458谭超Accepted
1196KB
59ms
C2901 bytes2023-05-03 13:41:03
1012172022212458谭超Wrong Answer
1196KB
57ms
C2900 bytes2023-05-03 13:38:06
1012102022212458谭超Wrong Answer
1196KB
54ms
C2882 bytes2023-05-03 13:29:43
1012092022212458谭超Wrong Answer
1196KB
59ms
C2982 bytes2023-05-03 13:28:32
968172022212458谭超Wrong Answer
1068KB
10ms
C943 bytes2023-04-27 23:08:48
965352022212458谭超Compile Error
0KB
0ms
C1693 bytes2023-04-27 16:26:02
965322022212458谭超Runtime Error
1196KB
11ms
C1491 bytes2023-04-27 16:20:29
965102022212458谭超*Accepted65379
1192KB
12ms
C1691 bytes2023-04-27 15:39:26
957322022212458谭超Wrong Answer
1196KB
60ms
C2500 bytes2023-04-26 10:55:24
957282022212458谭超Wrong Answer
1196KB
71ms
C2497 bytes2023-04-26 10:46:22
957102022212458谭超Wrong Answer
1196KB
71ms
C2494 bytes2023-04-26 10:01:14
957082022212458谭超Compile Error
0KB
0ms
C2495 bytes2023-04-26 09:59:48
957072022212458谭超Compile Error
0KB
0ms
C2498 bytes2023-04-26 09:59:09
957052022212458谭超Compile Error
0KB
0ms
C2481 bytes2023-04-26 09:56:56
957012022212458谭超Compile Error
0KB
0ms
C2485 bytes2023-04-26 09:54:54