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 14:02:52
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
867592022210145JeffAccepted
1192KB
10ms
C2155 bytes2023-04-11 13:45:17
867572022210145JeffWrong Answer
1192KB
10ms
C2271 bytes2023-04-11 13:40:31
866412022210145JeffWrong Answer
1192KB
10ms
C2233 bytes2023-04-10 23:45:47
859592022210145Jeff*Accepted72605
1192KB
10ms
C2101 bytes2023-04-09 23:36:37
859522022210145Jeff*Accepted64826
1192KB
10ms
C2060 bytes2023-04-09 23:28:37
859352022210145JeffAccepted
1196KB
11ms
C2285 bytes2023-04-09 22:58:34
858382022210145JeffAccepted
1068KB
12ms
C1890 bytes2023-04-09 19:24:40
858332022210145JeffCompile Error
0KB
0ms
C1828 bytes2023-04-09 19:16:45
852872022210145JeffRuntime Error
1068KB
11ms
C1893 bytes2023-04-08 21:42:08
844702022210145JeffRuntime Error
1068KB
8ms
C1095 bytes2023-04-07 15:41:06
832082022210145JeffWrong Answer
1068KB
11ms
C1594 bytes2023-04-05 20:40:23
831542022210145JeffRuntime Error
1068KB
8ms
C1107 bytes2023-04-05 20:05:05
785262022210145JeffRuntime Error
1072KB
10ms
C1790 bytes2023-04-02 12:56:51
785222022210145JeffRuntime Error
1072KB
10ms
C1768 bytes2023-04-02 12:50:22
782802022210145Jeff*Accepted65033
1072KB
13ms
C1876 bytes2023-04-01 23:20:19
782792022210145JeffWrong Answer
1072KB
12ms
C1622 bytes2023-04-01 23:19:21
782722022210145JeffWrong Answer
1072KB
10ms
C1686 bytes2023-04-01 23:13:36
782702022210145JeffWrong Answer
1072KB
11ms
C1780 bytes2023-04-01 23:12:29
782482022210145Jeff*Accepted65101
1068KB
12ms
C1898 bytes2023-04-01 22:47:37
782222022210145Jeff*Accepted64826
1192KB
11ms
C1925 bytes2023-04-01 22:27:10
782182022210145JeffWrong Answer
1196KB
10ms
C2340 bytes2023-04-01 22:25:01
742372022210145Jeff*Accepted65047
1196KB
12ms
C2534 bytes2023-03-30 11:57:40
742352022210145JeffWrong Answer
1196KB
10ms
C2602 bytes2023-03-30 11:53:30
742182022210145JeffWrong Answer
1196KB
9ms
C2650 bytes2023-03-30 11:38:07
742162022210145JeffWrong Answer
1196KB
12ms
C2650 bytes2023-03-30 11:36:43
735642022210145JeffWrong Answer
1192KB
13ms
C2017 bytes2023-03-29 21:49:06
735512022210145JeffWrong Answer
1192KB
12ms
C1992 bytes2023-03-29 21:46:23
735392022210145Jeff*Accepted64826
1192KB
11ms
C1932 bytes2023-03-29 21:39:19
735072022210145Jeff*Accepted64826
1192KB
8ms
C1760 bytes2023-03-29 21:25:42
734892022210145JeffCompile Error
0KB
0ms
C1747 bytes2023-03-29 21:17:25
734692022210145Jeff*Accepted64826
1192KB
11ms
C2251 bytes2023-03-29 21:12:58
734662022210145JeffCompile Error
0KB
0ms
C2254 bytes2023-03-29 21:12:38
733782022210145Jeff*Accepted64826
1192KB
10ms
C2358 bytes2023-03-29 20:46:41
731972022210145JeffAccepted
1200KB
10ms
C3369 bytes2023-03-29 19:45:50