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 10:47:03
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
841912022211261新西兰无水奶油Accepted
1192KB
10ms
C2237 bytes2023-04-06 22:56:00
841902022211261新西兰无水奶油Runtime Error
1192KB
6ms
C2249 bytes2023-04-06 22:55:31
841702022211261新西兰无水奶油Wrong Answer
1192KB
8ms
C2215 bytes2023-04-06 22:37:31
833602022211261新西兰无水奶油Wrong Answer
1192KB
13ms
C2298 bytes2023-04-05 22:04:43
833592022211261新西兰无水奶油Compile Error
0KB
0ms
C2302 bytes2023-04-05 22:04:24
833452022211261新西兰无水奶油Wrong Answer
1192KB
13ms
C2232 bytes2023-04-05 21:59:16
833302022211261新西兰无水奶油Wrong Answer
1192KB
10ms
C2205 bytes2023-04-05 21:54:11
833282022211261新西兰无水奶油Time Limit Exceed
1192KB
1772ms
C2197 bytes2023-04-05 21:52:18
833232022211261新西兰无水奶油Time Limit Exceed
1192KB
1769ms
C2197 bytes2023-04-05 21:49:33
833222022211261新西兰无水奶油Compile Error
0KB
0ms
C2196 bytes2023-04-05 21:48:53
833102022211261新西兰无水奶油Time Limit Exceed
1192KB
1774ms
C2193 bytes2023-04-05 21:42:13
832882022211261新西兰无水奶油Time Limit Exceed
1192KB
1769ms
C2256 bytes2023-04-05 21:34:35
832782022211261新西兰无水奶油Time Limit Exceed
1192KB
1767ms
C2259 bytes2023-04-05 21:32:06
832712022211261新西兰无水奶油Time Limit Exceed
1192KB
1777ms
C2284 bytes2023-04-05 21:28:02
832662022211261新西兰无水奶油Wrong Answer
1192KB
11ms
C2225 bytes2023-04-05 21:24:28
832652022211261新西兰无水奶油Wrong Answer
1192KB
10ms
C2158 bytes2023-04-05 21:23:06
832592022211261新西兰无水奶油Wrong Answer
1192KB
12ms
C2149 bytes2023-04-05 21:20:08
832562022211261新西兰无水奶油Wrong Answer
1192KB
9ms
C2145 bytes2023-04-05 21:17:53
832532022211261新西兰无水奶油Wrong Answer
1192KB
10ms
C2113 bytes2023-04-05 21:14:03
832492022211261新西兰无水奶油Wrong Answer
1192KB
13ms
C2160 bytes2023-04-05 21:11:53
832442022211261新西兰无水奶油Wrong Answer
1192KB
9ms
C2149 bytes2023-04-05 21:08:22
832382022211261新西兰无水奶油Wrong Answer
1192KB
11ms
C2207 bytes2023-04-05 21:06:52
832342022211261新西兰无水奶油Wrong Answer
1192KB
7ms
C2217 bytes2023-04-05 21:04:09
832332022211261新西兰无水奶油Wrong Answer
1192KB
11ms
C2254 bytes2023-04-05 21:02:11
832322022211261新西兰无水奶油*Accepted64610
1192KB
11ms
C2686 bytes2023-04-05 21:00:51
832292022211261新西兰无水奶油Time Limit Exceed
1192KB
1771ms
C2125 bytes2023-04-05 20:57:03
832272022211261新西兰无水奶油Time Limit Exceed
1192KB
1767ms
C2125 bytes2023-04-05 20:56:03