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 11:15:50
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
1024592022211321路人明ingWrong Answer
1196KB
11ms
C1735 bytes2023-05-04 23:58:40
1024572022211321路人明ingCompile Error
0KB
0ms
C1741 bytes2023-05-04 23:58:21
1024482022211321路人明ing*Accepted65047
1196KB
9ms
C2935 bytes2023-05-04 23:52:25
1023352022211321路人明ing*Accepted65033
1072KB
14ms
C1916 bytes2023-05-04 23:03:06
1023162022211321路人明ing*Accepted65033
1072KB
15ms
C1928 bytes2023-05-04 22:52:18
1023152022211321路人明ingWrong Answer
1072KB
10ms
C1928 bytes2023-05-04 22:52:08
1022812022211321路人明ingWrong Answer
1196KB
14ms
C1491 bytes2023-05-04 22:26:07
1022702022211321路人明ingWrong Answer
1192KB
11ms
C1507 bytes2023-05-04 22:17:20
1022492022211321路人明ingWrong Answer
1192KB
10ms
C1485 bytes2023-05-04 22:06:41
1022302022211321路人明ingWrong Answer
1192KB
12ms
C1449 bytes2023-05-04 21:56:35
1022122022211321路人明ingTime Limit Exceed
1192KB
3529ms
C1441 bytes2023-05-04 21:48:02
1021992022211321路人明ingOutput Limit Exceed
1192KB
3533ms
C1420 bytes2023-05-04 21:41:58
1021772022211321路人明ing*Accepted65979
1196KB
10ms
C1718 bytes2023-05-04 21:16:41
1021712022211321路人明ingWrong Answer
1196KB
11ms
C1716 bytes2023-05-04 21:15:01
1021652022211321路人明ingWrong Answer
1196KB
10ms
C1703 bytes2023-05-04 21:13:33
1021572022211321路人明ingWrong Answer
1192KB
13ms
C1541 bytes2023-05-04 21:09:23
1021482022211321路人明ingWrong Answer
1192KB
13ms
C1541 bytes2023-05-04 21:03:33
1021452022211321路人明ingWrong Answer
1192KB
11ms
C1542 bytes2023-05-04 20:59:29
957592022211321路人明ingTime Limit Exceed
1192KB
7055ms
C1344 bytes2023-04-26 11:41:34
755752022211321路人明ing*Accepted75531
1196KB
8ms
C1752 bytes2023-03-30 23:25:23
755702022211321路人明ing*Accepted75531
1196KB
12ms
C1766 bytes2023-03-30 23:23:21
740882022211321路人明ingWrong Answer
1196KB
12ms
C1761 bytes2023-03-30 10:16:08
712042022211321路人明ingWrong Answer
1196KB
12ms
C1739 bytes2023-03-28 00:22:23
711932022211321路人明ingWrong Answer
1196KB
12ms
C1739 bytes2023-03-28 00:14:09
711872022211321路人明ingWrong Answer
1196KB
12ms
C1737 bytes2023-03-28 00:11:11
711562022211321路人明ingWrong Answer
1196KB
10ms
C1737 bytes2023-03-27 23:48:10
704582022211321路人明ingWrong Answer
1192KB
12ms
C1565 bytes2023-03-27 16:35:36
704552022211321路人明ingWrong Answer
1068KB
13ms
C1341 bytes2023-03-27 16:32:20
704512022211321路人明ingWrong Answer
1068KB
12ms
C1347 bytes2023-03-27 16:27:50
688312022211321路人明ingWrong Answer
1068KB
11ms
C1308 bytes2023-03-25 22:13:18
688302022211321路人明ingWrong Answer
1068KB
7ms
C1306 bytes2023-03-25 22:07:08