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:23:11
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
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
1019672022212442范兼玮Wrong Answer
1196KB
11ms
C2658 bytes2023-05-04 15:54:26
1019642019211417咸鱼*Accepted65114
1196KB
12ms
C1666 bytes2023-05-04 15:52:41
1019632019211417咸鱼*Accepted65117
1196KB
10ms
C1607 bytes2023-05-04 15:51:59
1019622019211417咸鱼*Accepted64826
1192KB
11ms
C1925 bytes2023-05-04 15:51:42
1019612019211417咸鱼Accepted
1200KB
13ms
C2155 bytes2023-05-04 15:49:15
1019602019211417咸鱼Compile Error
0KB
0ms
C2155 bytes2023-05-04 15:48:39
1019572019211417咸鱼*Accepted65208
1200KB
11ms
C2126 bytes2023-05-04 15:45:39
1019562019211417咸鱼Wrong Answer
1200KB
12ms
C2160 bytes2023-05-04 15:44:30
1019552022212442范兼玮Wrong Answer
1192KB
10ms
C1145 bytes2023-05-04 15:44:04
1019542022212442范兼玮Wrong Answer
1192KB
10ms
C1146 bytes2023-05-04 15:43:41
1019532022212442范兼玮Wrong Answer
1192KB
11ms
C1148 bytes2023-05-04 15:43:05
1019492019211417咸鱼Wrong Answer
1200KB
13ms
C2132 bytes2023-05-04 15:39:54
1019482022212442范兼玮Wrong Answer
1192KB
8ms
C666 bytes2023-05-04 15:39:03
1019472019211417咸鱼Wrong Answer
1200KB
13ms
C2164 bytes2023-05-04 15:39:01
1019452019211417咸鱼Wrong Answer
1200KB
13ms
C2168 bytes2023-05-04 15:38:16
1019442019211417咸鱼Wrong Answer
1200KB
13ms
C2150 bytes2023-05-04 15:37:17
1019432022212442范兼玮Wrong Answer
1192KB
9ms
C673 bytes2023-05-04 15:37:15
1019422022212744aggylow*Accepted64994
1068KB
14ms
C2144 bytes2023-05-04 15:36:05
1019392022212744aggylow*Accepted64994
1068KB
13ms
C2060 bytes2023-05-04 15:33:16
1019362022212744aggylowWrong Answer
1068KB
9ms
C2030 bytes2023-05-04 15:32:10
1019322022212744aggylowWrong Answer
1068KB
11ms
C2053 bytes2023-05-04 15:31:14
1019302019211417咸鱼*Accepted65208
1200KB
13ms
C2118 bytes2023-05-04 15:31:03
1019242019211417咸鱼*Accepted64792
1192KB
12ms
C2037 bytes2023-05-04 15:25:41
1019232019211417咸鱼Wrong Answer
1192KB
9ms
C2030 bytes2023-05-04 15:24:23
1019202019211417咸鱼*Accepted64792
1192KB
11ms
C2042 bytes2023-05-04 15:16:37
1019192019211417咸鱼Runtime Error
1072KB
6ms
C3992 bytes2023-05-04 15:16:05
1019172022211637爱做梦的露西亚Accepted
1192KB
11ms
C2087 bytes2023-05-04 15:15:07
1019162019211417咸鱼*Accepted65208
1200KB
12ms
C2251 bytes2023-05-04 15:14:19
1019142022211637爱做梦的露西亚Wrong Answer
1192KB
10ms
C2082 bytes2023-05-04 15:14:01
1019062022212442范兼玮Wrong Answer
1196KB
12ms
C1449 bytes2023-05-04 14:53:11
1019012022212442范兼玮Runtime Error
1196KB
12ms
C2117 bytes2023-05-04 14:34:44
1019002022212442范兼玮Compile Error
0KB
0ms
C2124 bytes2023-05-04 14:34:01
1018992022212442范兼玮Runtime Error
1196KB
12ms
C2142 bytes2023-05-04 14:31:46
1018962022212442范兼玮Output Limit Exceed
1192KB
10ms
C2096 bytes2023-05-04 14:29:11
1018942022212442范兼玮Output Limit Exceed
1192KB
11ms
C1729 bytes2023-05-04 14:27:53
1018872022212442范兼玮Wrong Answer
1192KB
12ms
C3913 bytes2023-05-04 14:14:28
1018762022212458谭超Accepted
1068KB
14ms
C1047 bytes2023-05-04 13:46:56
1018742022212458谭超Wrong Answer
1068KB
11ms
C1843 bytes2023-05-04 13:43:19
1018732022212458谭超Wrong Answer
1192KB
11ms
C1398 bytes2023-05-04 13:38:13
1018712022212458谭超Compile Error
0KB
0ms
C2087 bytes2023-05-04 13:35:28
1018702022212458谭超Compile Error
0KB
0ms
C2009 bytes2023-05-04 13:32:49
1018692022212458谭超Wrong Answer
1068KB
11ms
C2035 bytes2023-05-04 13:21:44
1018682022212458谭超Accepted
1204KB
10ms
C1678 bytes2023-05-04 13:14:19