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-20 07:02:55
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
1024442021211214黃洪力Accepted
1192KB
12ms
C1990 bytes2023-05-04 23:49:13
1024362021211214黃洪力Wrong Answer
1192KB
12ms
C2005 bytes2023-05-04 23:46:37
1024352021211214黃洪力Wrong Answer
1192KB
12ms
C2076 bytes2023-05-04 23:46:20
1024322022212922sherryWrong Answer
1192KB
12ms
C1499 bytes2023-05-04 23:44:07
1024302021211214黃洪力Wrong Answer
1192KB
14ms
C2076 bytes2023-05-04 23:43:41
1024282022212922sherryCompile Error
0KB
0ms
C1495 bytes2023-05-04 23:42:32
1024222022212922sherry*Accepted101846
1192KB
9ms
C2082 bytes2023-05-04 23:38:58
1024162022212922sherryWrong Answer
1192KB
9ms
C1469 bytes2023-05-04 23:37:35
1024152021211214黃洪力Wrong Answer
1192KB
11ms
C2046 bytes2023-05-04 23:37:20
1024132022212922sherry*Accepted65107
1192KB
13ms
C2347 bytes2023-05-04 23:36:51
1024122021211214黃洪力Compile Error
0KB
0ms
C2055 bytes2023-05-04 23:36:48
1024052022212434HealthyCompile Error
0KB
0ms
C1704 bytes2023-05-04 23:31:32
1024022021211214黃洪力Wrong Answer
1192KB
14ms
C1975 bytes2023-05-04 23:30:33
1024012022212922sherryWrong Answer
1192KB
11ms
C1469 bytes2023-05-04 23:30:22
1023972022212434HealthyCompile Error
0KB
0ms
C1773 bytes2023-05-04 23:29:01
1023952021211214黃洪力Wrong Answer
1192KB
12ms
C1973 bytes2023-05-04 23:28:05
1023882021211214黃洪力Wrong Answer
1192KB
11ms
C1973 bytes2023-05-04 23:25:03
1023872022212434HealthyCompile Error
0KB
0ms
C1927 bytes2023-05-04 23:24:58
1023862021211214黃洪力Wrong Answer
1192KB
13ms
C1973 bytes2023-05-04 23:24:45
1023742022212922sherry*Accepted64826
1192KB
11ms
C1481 bytes2023-05-04 23:20:46
1023682021211214黃洪力Wrong Answer
1192KB
12ms
C1975 bytes2023-05-04 23:19:34
1023672022212922sherry*Accepted64826
1192KB
11ms
C1507 bytes2023-05-04 23:19:30
1023622021211214黃洪力Wrong Answer
1192KB
13ms
C1869 bytes2023-05-04 23:18:10
1023492021211214黃洪力Wrong Answer
1192KB
12ms
C1989 bytes2023-05-04 23:12:24
1023452022212922sherryWrong Answer
1192KB
10ms
C1518 bytes2023-05-04 23:09:41
1023402022212434Healthy*Accepted91204
1068KB
9ms
C1427 bytes2023-05-04 23:05:17
1023372021211214黃洪力Wrong Answer
1192KB
9ms
C1983 bytes2023-05-04 23:03:33
1023092022212922sherryWrong Answer
1192KB
11ms
C1526 bytes2023-05-04 22:45:37
1023052022212922sherryWrong Answer
1192KB
10ms
C1515 bytes2023-05-04 22:44:56
1022992022212922sherryWrong Answer
1192KB
9ms
C1578 bytes2023-05-04 22:39:54
1022972022212434HealthyWrong Answer
1068KB
12ms
C1593 bytes2023-05-04 22:37:52
1022952022212434HealthyWrong Answer
1192KB
11ms
C2686 bytes2023-05-04 22:37:21
1022932022212434HealthyCompile Error
0KB
0ms
C1617 bytes2023-05-04 22:36:29
1022912022212922sherryTime Limit Exceed
1068KB
8815ms
C1503 bytes2023-05-04 22:35:39
1022772022210177牛梓帆Accepted
1196KB
11ms
C4207 bytes2023-05-04 22:22:50
1022762022210177牛梓帆Presentation Error
1196KB
10ms
C4211 bytes2023-05-04 22:21:35
1022722017211617赵鹏飞*Accepted65050
1068KB
12ms
C1863 bytes2023-05-04 22:18:03
1022712017211617赵鹏飞*Accepted64956
1192KB
12ms
C2211 bytes2023-05-04 22:17:25
1022692017211617赵鹏飞*Accepted64954
1192KB
13ms
C2048 bytes2023-05-04 22:16:38
1022662017211617赵鹏飞Compile Error
0KB
0ms
C2491 bytes2023-05-04 22:15:52
1022632017211617赵鹏飞*Accepted64610
1192KB
11ms
C2655 bytes2023-05-04 22:13:53
1022572017211617赵鹏飞Compile Error
0KB
0ms
C2795 bytes2023-05-04 22:11:40
1022552017211617赵鹏飞*Accepted64825
1200KB
11ms
C3511 bytes2023-05-04 22:08:47
1022522021211214黃洪力Wrong Answer
1192KB
9ms
C2539 bytes2023-05-04 22:07:34
1022482021211214黃洪力Runtime Error
1192KB
6ms
C2535 bytes2023-05-04 22:06:34
1022442021211214黃洪力Runtime Error
1192KB
6ms
C2537 bytes2023-05-04 22:03:39
1022432021211214黃洪力Runtime Error
1192KB
5ms
C2538 bytes2023-05-04 22:02:51
1022392022212922sherryWrong Answer
1192KB
11ms
C1387 bytes2023-05-04 22:00:20
1022382022210177牛梓帆*Accepted64826
1192KB
11ms
C2136 bytes2023-05-04 22:00:02
1022352021211214黃洪力Runtime Error
1192KB
6ms
C2464 bytes2023-05-04 21:58:23