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-20 00:56:39
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
1020782022211322豌豆黄冠Compile Error
0KB
0ms
C2703 bytes2023-05-04 19:19:42
1020772022211241qy*Accepted64826
1192KB
12ms
C2302 bytes2023-05-04 19:19:13
1020752022211241qy*Accepted64994
1068KB
10ms
C2060 bytes2023-05-04 19:17:43
1020742022211241qy*Accepted101846
1192KB
10ms
C2025 bytes2023-05-04 19:16:48
1020722022211241qyWrong Answer
1068KB
10ms
C315 bytes2023-05-04 19:16:21
1020692022211241qy*Accepted64825
1200KB
12ms
C3566 bytes2023-05-04 19:09:48
1020632022211341biomooAccepted
1192KB
12ms
C1753 bytes2023-05-04 18:10:50
1020612022211341biomooCompile Error
0KB
0ms
C1751 bytes2023-05-04 18:09:02
1020492022211313canyi*Accepted65107
1192KB
11ms
C2347 bytes2023-05-04 17:56:52
1020472022211313canyi*Accepted88404
1196KB
13ms
C2182 bytes2023-05-04 17:55:07
1020432022211313canyi*Accepted64826
1192KB
13ms
C1927 bytes2023-05-04 17:47:44
1020412022211327ですRuntime Error
1192KB
12ms
C1483 bytes2023-05-04 17:44:36
1020342022211327ですRuntime Error
1192KB
9ms
C1506 bytes2023-05-04 17:26:19
1020022022211245李佳豪*Accepted64826
1192KB
11ms
C2572 bytes2023-05-04 16:17:36
1019862022211290pvz2408*Accepted64826
1192KB
13ms
C2560 bytes2023-05-04 16:04:15
1019842022211290pvz2408Compile Error
0KB
0ms
C2564 bytes2023-05-04 16:03:48
1019752021211266守旧派--中华王源Wrong Answer
1196KB
12ms
C1613 bytes2023-05-04 16:00:14
1019712021211266守旧派--中华王源Wrong Answer
1196KB
11ms
C1602 bytes2023-05-04 15:55:37
1019692021211266守旧派--中华王源Compile Error
0KB
0ms
C1604 bytes2023-05-04 15:55:24
1019512022211290pvz2408*Accepted64825
1200KB
11ms
C3111 bytes2023-05-04 15:40:41
1019382022211290pvz2408*Accepted64825
1200KB
10ms
C3171 bytes2023-05-04 15:33:13
1019342022211290pvz2408*Accepted64825
1200KB
12ms
C3318 bytes2023-05-04 15:31:50
1019292022211290pvz2408Compile Error
0KB
0ms
C3316 bytes2023-05-04 15:30:27
1019282022211290pvz2408Compile Error
0KB
0ms
C3316 bytes2023-05-04 15:30:04
1019272021211266守旧派--中华王源Wrong Answer
1196KB
10ms
C1587 bytes2023-05-04 15:29:23
1019262022211290pvz2408*Accepted64825
1200KB
13ms
C3226 bytes2023-05-04 15:28:28
1019252022211290pvz2408Output Limit Exceed
1200KB
10ms
C3025 bytes2023-05-04 15:25:49
1018802021211266守旧派--中华王源Wrong Answer
1196KB
11ms
C1558 bytes2023-05-04 13:51:54
1018792021211266守旧派--中华王源Compile Error
0KB
0ms
C1558 bytes2023-05-04 13:51:31
1018512022211327です*Accepted64826
1192KB
11ms
C1552 bytes2023-05-04 12:20:40
1018502022211327ですOutput Limit Exceed
1200KB
11ms
C2199 bytes2023-05-04 12:00:30
1018492021211266守旧派--中华王源Wrong Answer
1192KB
11ms
C1552 bytes2023-05-04 12:00:04
1018482021211266守旧派--中华王源Wrong Answer
1192KB
11ms
C1550 bytes2023-05-04 11:59:03
1018462022211322豌豆黄冠Accepted
1192KB
9ms
C2291 bytes2023-05-04 11:57:38
1018452022211354asdfAccepted
1192KB
12ms
C1160 bytes2023-05-04 11:54:31
1018442021211266守旧派--中华王源Wrong Answer
1192KB
12ms
C1551 bytes2023-05-04 11:50:40
1018432021211266守旧派--中华王源Compile Error
0KB
0ms
C1567 bytes2023-05-04 11:48:53
1018412022211354asdfPresentation Error
1192KB
11ms
C1136 bytes2023-05-04 11:46:24
1018382022211354asdfWrong Answer
1192KB
14ms
C1221 bytes2023-05-04 11:36:19
1018342022211354asdfPresentation Error
1192KB
10ms
C1121 bytes2023-05-04 11:28:26
1018312022211354asdfAccepted
1192KB
13ms
C1482 bytes2023-05-04 11:26:15
1018302022211354asdfRuntime Error
1196KB
13ms
C1480 bytes2023-05-04 11:23:24
1018212022211354asdfAccepted
1068KB
9ms
C809 bytes2023-05-04 11:09:22
1018182022211266lyt6666*Accepted65336
1068KB
9ms
C830 bytes2023-05-04 11:02:24
1018172022211322豌豆黄冠*Accepted65025
1192KB
10ms
C2079 bytes2023-05-04 11:01:06
1018162022211350...Accepted
1068KB
12ms
C1384 bytes2023-05-04 10:55:05
1018132022211266lyt6666*Accepted65047
1196KB
10ms
C2921 bytes2023-05-04 10:51:10
1018112022211322豌豆黄冠Compile Error
0KB
0ms
C2226 bytes2023-05-04 10:49:52
1018102022211350...Time Limit Exceed
1068KB
8813ms
C1371 bytes2023-05-04 10:47:04
1018092022211350...Compile Error
0KB
0ms
C1351 bytes2023-05-04 10:46:43