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 16:49:49
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
983182022211357Accepted
1068KB
10ms
C1537 bytes2023-04-30 15:54:35
982732022211357Wrong Answer
1068KB
12ms
C1516 bytes2023-04-30 15:34:14
975592022211357Accepted
1192KB
10ms
C1204 bytes2023-04-29 18:07:31
975572022211357Wrong Answer
1192KB
9ms
C1199 bytes2023-04-29 18:05:03
975552022211357Wrong Answer
1192KB
9ms
C1148 bytes2023-04-29 18:01:27
975542022211357Wrong Answer
1192KB
9ms
C1149 bytes2023-04-29 18:01:10
975512022211357Wrong Answer
1192KB
10ms
C1192 bytes2023-04-29 17:57:21
975502022211357Wrong Answer
1192KB
11ms
C1142 bytes2023-04-29 17:56:25
975492022211357Wrong Answer
1192KB
9ms
C1143 bytes2023-04-29 17:56:07
975342022211357Wrong Answer
1192KB
10ms
C1117 bytes2023-04-29 17:45:17
975112022211357Wrong Answer
1192KB
11ms
C1080 bytes2023-04-29 17:28:19
974762022211357Output Limit Exceed
1192KB
12ms
C1282 bytes2023-04-29 16:57:41
896732022211357Accepted
1196KB
15ms
C2500 bytes2023-04-16 19:29:00
893952022211357Wrong Answer
1196KB
11ms
C2468 bytes2023-04-15 20:33:04
893942022211357Compile Error
0KB
0ms
C2468 bytes2023-04-15 20:32:39
893932022211357Compile Error
0KB
0ms
C2468 bytes2023-04-15 20:32:18
893922022211357Wrong Answer
1196KB
12ms
C2468 bytes2023-04-15 20:31:46
893912022211357Wrong Answer
1192KB
11ms
C2468 bytes2023-04-15 20:31:17
882342022211357Accepted
1192KB
14ms
C2453 bytes2023-04-13 12:09:48
882332022211357Output Limit Exceed
1192KB
6ms
C2445 bytes2023-04-13 12:09:03
882162022211357Accepted
1192KB
13ms
C2676 bytes2023-04-13 11:48:18
882072022211357Wrong Answer
1192KB
12ms
C2543 bytes2023-04-13 11:37:37
882062022211357Wrong Answer
1192KB
13ms
C2471 bytes2023-04-13 11:36:35
882032022211357Wrong Answer
1192KB
12ms
C2434 bytes2023-04-13 11:31:59
882012022211357Wrong Answer
1192KB
10ms
C2440 bytes2023-04-13 11:31:11
881992022211357Wrong Answer
1192KB
11ms
C2424 bytes2023-04-13 11:30:37
881952022211357Wrong Answer
1192KB
11ms
C2412 bytes2023-04-13 11:25:51
881922022211357Wrong Answer
1192KB
11ms
C2412 bytes2023-04-13 11:25:07
881902022211357Wrong Answer
1192KB
14ms
C2412 bytes2023-04-13 11:24:15
881862022211357Wrong Answer
1192KB
13ms
C2397 bytes2023-04-13 11:20:56
881842022211357Wrong Answer
1192KB
14ms
C2369 bytes2023-04-13 11:20:23
881822022211357Wrong Answer
1192KB
9ms
C2344 bytes2023-04-13 11:19:28
881802022211357Wrong Answer
1192KB
11ms
C2342 bytes2023-04-13 11:18:56
881782022211357Wrong Answer
1192KB
12ms
C2316 bytes2023-04-13 11:16:45
881772022211357Wrong Answer
1192KB
12ms
C2318 bytes2023-04-13 11:15:46
881762022211357Compile Error
0KB
0ms
C2319 bytes2023-04-13 11:15:24
881622022211357Wrong Answer
1192KB
11ms
C2314 bytes2023-04-13 10:55:50
881602022211357Wrong Answer
1192KB
13ms
C2314 bytes2023-04-13 10:53:11
881592022211357Wrong Answer
1192KB
12ms
C2317 bytes2023-04-13 10:50:50
881582022211357Wrong Answer
1192KB
14ms
C2411 bytes2023-04-13 10:49:24
881572022211357Output Limit Exceed
1192KB
6ms
C2401 bytes2023-04-13 10:48:41
874092022211357Output Limit Exceed
1192KB
6ms
C2232 bytes2023-04-12 00:22:03
874062022211357Wrong Answer
1192KB
13ms
C2206 bytes2023-04-12 00:16:21
874042022211357Wrong Answer
1192KB
12ms
C2162 bytes2023-04-12 00:12:47
874002022211357Wrong Answer
1192KB
11ms
C2056 bytes2023-04-12 00:08:14
863062022211357Wrong Answer
1192KB
14ms
C2026 bytes2023-04-10 18:08:02
863052022211357Wrong Answer
1192KB
13ms
C1863 bytes2023-04-10 17:59:01
863042022211357Wrong Answer
1192KB
13ms
C1865 bytes2023-04-10 17:58:30
863022022211357Wrong Answer
1068KB
12ms
C1725 bytes2023-04-10 17:53:36
862972022211357Wrong Answer
1068KB
12ms
C1677 bytes2023-04-10 17:46:52