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 03:51:00
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
1020682022211637爱做梦的露西亚*Accepted53456
1192KB
13ms
C1705 bytes2023-05-04 19:00:02
1020672022211637爱做梦的露西亚Output Limit Exceed
1192KB
11ms
C1924 bytes2023-05-04 18:59:41
1020662022211637爱做梦的露西亚*Accepted53456
1192KB
9ms
C1803 bytes2023-05-04 18:58:32
1020652022211637爱做梦的露西亚Wrong Answer
1192KB
11ms
C1811 bytes2023-05-04 18:55:54
1020642022212010蔡正舟*Accepted65379
1192KB
12ms
C1715 bytes2023-05-04 18:16:35
1020622022212442范兼玮*Accepted74125
1192KB
10ms
C1800 bytes2023-05-04 18:09:28
1020572022212010蔡正舟Wrong Answer
1192KB
10ms
C1715 bytes2023-05-04 18:05:35
1020552022212442范兼玮Wrong Answer
1192KB
12ms
C1801 bytes2023-05-04 18:03:20
1020542022212010蔡正舟Wrong Answer
1192KB
11ms
C1770 bytes2023-05-04 18:02:28
1020532022212442范兼玮Presentation Error
1192KB
12ms
C1800 bytes2023-05-04 18:02:01
1020512022212010蔡正舟Wrong Answer
1196KB
12ms
C1818 bytes2023-05-04 17:58:13
1020402022212922sherryWrong Answer
1192KB
11ms
C1576 bytes2023-05-04 17:43:27
1020372022212922sherryWrong Answer
1192KB
9ms
C1501 bytes2023-05-04 17:38:24
1020302019211417咸鱼Output Limit Exceed
1192KB
11ms
C1878 bytes2023-05-04 17:04:39
1020232019211417咸鱼Output Limit Exceed
1192KB
12ms
C1755 bytes2023-05-04 16:51:05
1020212019211417咸鱼Wrong Answer
1192KB
10ms
C1718 bytes2023-05-04 16:49:50
1020202019211417咸鱼Output Limit Exceed
1192KB
14ms
C1482 bytes2023-05-04 16:49:10
1020162019211417咸鱼*Accepted53456
1192KB
10ms
C1467 bytes2023-05-04 16:45:56
1020132019211417咸鱼Wrong Answer
1192KB
9ms
C1420 bytes2023-05-04 16:43:51
1020112022212442范兼玮Runtime Error
1192KB
11ms
C1577 bytes2023-05-04 16:42:52
1020102019211417咸鱼*Accepted65050
1068KB
12ms
C1887 bytes2023-05-04 16:31:46
1020092019211417咸鱼Runtime Error
1068KB
10ms
C2102 bytes2023-05-04 16:30:59
1020082019211417咸鱼*Accepted64994
1068KB
12ms
C2060 bytes2023-05-04 16:30:23
1020072019211417咸鱼*Accepted65101
1068KB
13ms
C1931 bytes2023-05-04 16:29:59
1020062019211417咸鱼*Accepted64956
1192KB
13ms
C2211 bytes2023-05-04 16:26:14
1020052019211417咸鱼Wrong Answer
1068KB
11ms
C2536 bytes2023-05-04 16:25:28
1020042019211417咸鱼*Accepted101846
1192KB
11ms
C2082 bytes2023-05-04 16:24:48
1020032019211417咸鱼*Accepted65047
1196KB
10ms
C2935 bytes2023-05-04 16:23:41
1020012019211417咸鱼*Accepted64826
1192KB
13ms
C1820 bytes2023-05-04 16:17:21
1020002019211417咸鱼*Accepted64826
1192KB
11ms
C1662 bytes2023-05-04 16:14:35
1019982019211417咸鱼*Accepted64826
1192KB
11ms
C1553 bytes2023-05-04 16:12:07
1019972022212442范兼玮Accepted
1196KB
11ms
C3333 bytes2023-05-04 16:11:06
1019962022212442范兼玮Wrong Answer
1196KB
12ms
C2835 bytes2023-05-04 16:10:06
1019952022212442范兼玮Wrong Answer
1196KB
12ms
C2755 bytes2023-05-04 16:09:54
1019942019211417咸鱼*Accepted64826
1192KB
10ms
C1779 bytes2023-05-04 16:09:54
1019932022212442范兼玮Wrong Answer
1196KB
11ms
C3334 bytes2023-05-04 16:09:37
1019922022212442范兼玮Wrong Answer
1196KB
11ms
C2660 bytes2023-05-04 16:06:44
1019912022212442范兼玮Wrong Answer
1196KB
10ms
C1852 bytes2023-05-04 16:06:24
1019902022212442范兼玮Wrong Answer
1196KB
10ms
C1991 bytes2023-05-04 16:05:23
1019892022212442范兼玮Wrong Answer
1196KB
9ms
C2649 bytes2023-05-04 16:05:00
1019882022212442范兼玮Wrong Answer
1196KB
11ms
C2649 bytes2023-05-04 16:04:42
1019872022212442范兼玮Wrong Answer
1196KB
12ms
C2660 bytes2023-05-04 16:04:19
1019852022212442范兼玮Wrong Answer
1196KB
11ms
C2647 bytes2023-05-04 16:04:09
1019802022212442范兼玮Wrong Answer
1196KB
11ms
C2673 bytes2023-05-04 16:02:10
1019792022212442范兼玮Compile Error
0KB
0ms
C2672 bytes2023-05-04 16:01:59
1019772022212442范兼玮Wrong Answer
1196KB
9ms
C2660 bytes2023-05-04 16:01:41
1019762022212744aggylowAccepted
1080KB
13ms
C1881 bytes2023-05-04 16:01:10
1019742022212744aggylowCompile Error
0KB
0ms
C1976 bytes2023-05-04 15:58:20
1019722022212744aggylowCompile Error
0KB
0ms
C2000 bytes2023-05-04 15:57:03
1019702022212442范兼玮Wrong Answer
1196KB
12ms
C2660 bytes2023-05-04 15:55:36