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 18:29:46
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
1017022022212247马梓洋*Accepted65025
1192KB
11ms
C2038 bytes2023-05-03 23:27:38
1014532022212247马梓洋Wrong Answer
1192KB
10ms
C1692 bytes2023-05-03 19:02:37
1014502022212247马梓洋Time Limit Exceed
1192KB
1769ms
C2141 bytes2023-05-03 18:59:49
1014472022212247马梓洋Wrong Answer
1192KB
12ms
C1692 bytes2023-05-03 18:57:37
1014422022212247马梓洋Wrong Answer
1192KB
12ms
C1696 bytes2023-05-03 18:55:39
1014322022212247马梓洋Wrong Answer
1192KB
11ms
C1694 bytes2023-05-03 18:49:54
1014282022212247马梓洋Wrong Answer
1192KB
11ms
C1692 bytes2023-05-03 18:43:52
1010672022212247马梓洋*Accepted64994
1068KB
9ms
C1907 bytes2023-05-03 09:33:58
1008212022212247马梓洋Wrong Answer
1068KB
10ms
C1038 bytes2023-05-03 00:16:03
984702022212247马梓洋Wrong Answer
1068KB
10ms
C957 bytes2023-04-30 17:49:48
984692022212247马梓洋*Accepted64826
1192KB
12ms
C1359 bytes2023-04-30 17:48:53
984672022212247马梓洋Runtime Error
1192KB
10ms
C1359 bytes2023-04-30 17:47:14
889372022212247马梓洋Wrong Answer
1192KB
12ms
C1692 bytes2023-04-14 17:18:54
889312022212247马梓洋Runtime Error
1068KB
10ms
C1947 bytes2023-04-14 17:09:21
889302022212247马梓洋Compile Error
0KB
0ms
C2048 bytes2023-04-14 17:08:47
889122022212247马梓洋Wrong Answer
1068KB
11ms
C1154 bytes2023-04-14 16:57:15
889072022212247马梓洋Wrong Answer
1068KB
10ms
C1048 bytes2023-04-14 16:54:55
889052022212247马梓洋Wrong Answer
1068KB
11ms
C957 bytes2023-04-14 16:52:42
889002022212247马梓洋Wrong Answer
1068KB
13ms
C974 bytes2023-04-14 16:48:55
884412022212247马梓洋Accepted
1200KB
15ms
C7958 bytes2023-04-13 20:26:08
883202022212247马梓洋Wrong Answer
1068KB
11ms
C1046 bytes2023-04-13 14:39:55
883192022212247马梓洋Wrong Answer
1068KB
9ms
C1046 bytes2023-04-13 14:38:44
883172022212247马梓洋Wrong Answer
1068KB
12ms
C1029 bytes2023-04-13 14:36:52
882662022212247马梓洋Wrong Answer
1176KB
10ms
C947 bytes2023-04-13 13:24:22
881282022212247马梓洋Runtime Error
1192KB
10ms
C1359 bytes2023-04-13 09:39:50
881272022212247马梓洋Runtime Error
1192KB
10ms
C1356 bytes2023-04-13 09:36:39
881262022212247马梓洋Wrong Answer
1192KB
11ms
C1684 bytes2023-04-13 09:27:58
881252022212247马梓洋Wrong Answer
1192KB
11ms
C1684 bytes2023-04-13 09:27:40
881242022212247马梓洋Wrong Answer
1192KB
10ms
C1684 bytes2023-04-13 09:27:19
881232022212247马梓洋Wrong Answer
1192KB
9ms
C1684 bytes2023-04-13 09:26:56
881222022212247马梓洋Wrong Answer
1192KB
12ms
C1684 bytes2023-04-13 09:26:21
876682022212247马梓洋Wrong Answer
1192KB
10ms
C1662 bytes2023-04-12 16:58:33
872872022212247马梓洋Wrong Answer
1192KB
10ms
C1356 bytes2023-04-11 22:58:59
872792022212247马梓洋Wrong Answer
1192KB
11ms
C1372 bytes2023-04-11 22:58:08
871742022212247马梓洋Runtime Error
1072KB
6ms
C471 bytes2023-04-11 21:27:47
871682022212247马梓洋Wrong Answer
1200KB
15ms
C7952 bytes2023-04-11 21:20:36
871612022212247马梓洋Wrong Answer
1200KB
14ms
C7950 bytes2023-04-11 21:17:45
870672022212247马梓洋Wrong Answer
1200KB
13ms
C7948 bytes2023-04-11 20:15:28
870632022212247马梓洋Wrong Answer
1200KB
15ms
C7952 bytes2023-04-11 20:14:14
870572022212247马梓洋Wrong Answer
1200KB
14ms
C7950 bytes2023-04-11 20:12:53
863592022212247马梓洋Wrong Answer
1200KB
16ms
C7948 bytes2023-04-10 19:59:03
863482022212247马梓洋Wrong Answer
1200KB
16ms
C7950 bytes2023-04-10 19:48:29