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-19 15:49:18
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
1024402022211322豌豆黄冠Runtime Error
1072KB
12ms
C1953 bytes2023-05-04 23:47:49
1021252022211322豌豆黄冠Runtime Error
1072KB
10ms
C1955 bytes2023-05-04 20:33:31
1021232022211322豌豆黄冠Compile Error
0KB
0ms
C1961 bytes2023-05-04 20:32:33
1021222022211322豌豆黄冠Compile Error
0KB
0ms
C1959 bytes2023-05-04 20:31:58
1021162022211322豌豆黄冠*Accepted65033
1072KB
14ms
C1838 bytes2023-05-04 20:28:05
1020822022211322豌豆黄冠*Accepted64826
1192KB
9ms
C2763 bytes2023-05-04 19:27:05
1020812022211322豌豆黄冠*Accepted64826
1192KB
11ms
C2626 bytes2023-05-04 19:25:33
1020802022211322豌豆黄冠Runtime Error
1192KB
10ms
C2697 bytes2023-05-04 19:23:18
1020792022211322豌豆黄冠Runtime Error
1192KB
11ms
C2714 bytes2023-05-04 19:20:20
1020782022211322豌豆黄冠Compile Error
0KB
0ms
C2703 bytes2023-05-04 19:19:42
1018462022211322豌豆黄冠Accepted
1192KB
9ms
C2291 bytes2023-05-04 11:57:38
1018172022211322豌豆黄冠*Accepted65025
1192KB
10ms
C2079 bytes2023-05-04 11:01:06
1018112022211322豌豆黄冠Compile Error
0KB
0ms
C2226 bytes2023-05-04 10:49:52
1018082022211322豌豆黄冠*Accepted65025
1192KB
13ms
C2050 bytes2023-05-04 10:46:15
1018072022211322豌豆黄冠Compile Error
0KB
0ms
C2051 bytes2023-05-04 10:45:18
1018032022211322豌豆黄冠*Accepted65025
1192KB
10ms
C2063 bytes2023-05-04 10:42:36
1018002022211322豌豆黄冠*Accepted65025
1192KB
10ms
C2061 bytes2023-05-04 10:39:10
1016112022211322豌豆黄冠*Accepted64826
1192KB
13ms
C2595 bytes2023-05-03 21:44:34
1016092022211322豌豆黄冠Compile Error
0KB
0ms
C2595 bytes2023-05-03 21:43:14
962862022211322豌豆黄冠Accepted
1200KB
12ms
C2472 bytes2023-04-26 23:08:49
962792022211322豌豆黄冠Wrong Answer
1200KB
12ms
C2469 bytes2023-04-26 23:02:46
962742022211322豌豆黄冠Wrong Answer
1200KB
13ms
C2464 bytes2023-04-26 22:47:17
962642022211322豌豆黄冠Wrong Answer
1192KB
12ms
C2494 bytes2023-04-26 22:28:33
962602022211322豌豆黄冠Time Limit Exceed
1192KB
1763ms
C2446 bytes2023-04-26 22:25:20
962542022211322豌豆黄冠Wrong Answer
1192KB
13ms
C2417 bytes2023-04-26 22:19:56
962532022211322豌豆黄冠Wrong Answer
1192KB
13ms
C2417 bytes2023-04-26 22:19:10
915112022211322豌豆黄冠Wrong Answer
1192KB
10ms
C2416 bytes2023-04-19 22:36:35
914972022211322豌豆黄冠Wrong Answer
1192KB
9ms
C2305 bytes2023-04-19 22:18:07
914882022211322豌豆黄冠Time Limit Exceed
1192KB
1766ms
C2249 bytes2023-04-19 22:01:04
914872022211322豌豆黄冠Compile Error
0KB
0ms
C2248 bytes2023-04-19 22:00:27
914842022211322豌豆黄冠Time Limit Exceed
1192KB
1773ms
C2247 bytes2023-04-19 21:50:22
914832022211322豌豆黄冠Compile Error
0KB
0ms
C2247 bytes2023-04-19 21:49:46