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 13:55:40
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
1017522022212379visirAccepted
1192KB
11ms
C5543 bytes2023-05-04 02:49:51
1017512022212379visirAccepted
1192KB
12ms
C6493 bytes2023-05-04 02:49:12
1017502022212379visirRuntime Error
1192KB
12ms
C6520 bytes2023-05-04 02:49:01
1017492022212379visir*Accepted66761
1192KB
12ms
C5429 bytes2023-05-04 02:42:54
1017482022212379visirWrong Answer
1196KB
11ms
C5207 bytes2023-05-04 02:42:10
1017472022212379visirAccepted
1072KB
10ms
C1752 bytes2023-05-04 02:31:49
1017462022212379visir*Accepted67292
1192KB
11ms
C2417 bytes2023-05-04 02:23:39
1017452022212379visirWrong Answer
1196KB
12ms
C4510 bytes2023-05-04 02:07:19
1017442022212379visirWrong Answer
1196KB
10ms
C4514 bytes2023-05-04 02:05:57
1017432022212379visirWrong Answer
1196KB
11ms
C4804 bytes2023-05-04 01:52:57
1017422022212379visir*Accepted66761
1192KB
11ms
C1842 bytes2023-05-04 01:40:13
1017412022212379visirWrong Answer
1192KB
12ms
C1829 bytes2023-05-04 01:40:01
1017402022212379visirRuntime Error
1192KB
13ms
C1877 bytes2023-05-04 01:39:46
1017392022212379visirWrong Answer
1192KB
11ms
C1829 bytes2023-05-04 01:39:07
1017382022212379visir*Accepted64826
1192KB
11ms
C1713 bytes2023-05-04 01:36:12
1017372022212379visirCompile Error
0KB
0ms
C1864 bytes2023-05-04 01:35:38
1017362022212379visirWrong Answer
1196KB
12ms
C5051 bytes2023-05-04 01:29:46
1017352022212379visirWrong Answer
1196KB
11ms
C5051 bytes2023-05-04 01:27:43
1017342022212379visirWrong Answer
1196KB
12ms
C5051 bytes2023-05-04 01:26:42
1017332022212379visirWrong Answer
1196KB
13ms
C5051 bytes2023-05-04 01:25:42
1017322022212379visirWrong Answer
1196KB
11ms
C4980 bytes2023-05-04 01:19:19
1017312022212379visirAccepted
1192KB
11ms
C1307 bytes2023-05-04 01:03:08
1017292022212379visirWrong Answer
1192KB
9ms
C1670 bytes2023-05-04 00:27:32
1017282022212379visirWrong Answer
1192KB
11ms
C888 bytes2023-05-04 00:17:52
1017272022212379visirWrong Answer
1192KB
10ms
C916 bytes2023-05-04 00:09:58
1017262022212379visirWrong Answer
1192KB
10ms
C917 bytes2023-05-04 00:06:33
1017252022212379visirWrong Answer
1192KB
13ms
C915 bytes2023-05-04 00:06:18
1017242022212379visirWrong Answer
1192KB
10ms
C919 bytes2023-05-04 00:06:07
1017232022212379visirWrong Answer
1192KB
10ms
C913 bytes2023-05-04 00:05:22
1017222022212379visirWrong Answer
1192KB
10ms
C913 bytes2023-05-04 00:05:10
1017212022212379visirWrong Answer
1192KB
11ms
C944 bytes2023-05-04 00:03:30
1017202022212379visirWrong Answer
1192KB
13ms
C940 bytes2023-05-04 00:02:56
1017192022212379visirWrong Answer
1192KB
8ms
C912 bytes2023-05-04 00:02:03
1017182022212379visirWrong Answer
1192KB
9ms
C913 bytes2023-05-04 00:01:23
1017172022212379visirWrong Answer
1192KB
7ms
C880 bytes2023-05-04 00:00:42
1017162022212379visirWrong Answer
1192KB
9ms
C838 bytes2023-05-03 23:59:34
1017152022212379visirWrong Answer
1192KB
13ms
C835 bytes2023-05-03 23:58:25
1017082022212379visirWrong Answer
1196KB
11ms
C4999 bytes2023-05-03 23:32:28
1017072022212379visirWrong Answer
1196KB
14ms
C4999 bytes2023-05-03 23:31:56
1017062022212379visirWrong Answer
1196KB
12ms
C4999 bytes2023-05-03 23:31:38
1017052022212379visirWrong Answer
1196KB
12ms
C4999 bytes2023-05-03 23:30:02
1017042022212379visirWrong Answer
1196KB
12ms
C4999 bytes2023-05-03 23:29:29
1017032022212379visirWrong Answer
1196KB
9ms
C4999 bytes2023-05-03 23:29:10
1017012022212379visirWrong Answer
1196KB
12ms
C5020 bytes2023-05-03 23:27:32
1016992022212379visirWrong Answer
1196KB
11ms
C5020 bytes2023-05-03 23:26:50
1016982022212379visirRuntime Error
1196KB
9ms
C5047 bytes2023-05-03 23:26:25
1016972022212379visirWrong Answer
1196KB
8ms
C5020 bytes2023-05-03 23:25:59
1016962022212379visirRuntime Error
1196KB
9ms
C5047 bytes2023-05-03 23:25:00
1016952022212379visirWrong Answer
1196KB
12ms
C4987 bytes2023-05-03 23:15:45
1016932022212379visirWrong Answer
1196KB
10ms
C4987 bytes2023-05-03 23:10:20