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 12:24:28
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
854922022211306刘伟Accepted
1076KB
12ms
C883 bytes2023-04-09 12:22:18
854792022211306刘伟Output Limit Exceed
1076KB
12ms
C874 bytes2023-04-09 11:59:53
854702022211306刘伟Output Limit Exceed
1076KB
11ms
C874 bytes2023-04-09 11:22:17
854612022211306刘伟Output Limit Exceed
1076KB
10ms
C839 bytes2023-04-09 10:58:11
854562022211306刘伟Output Limit Exceed
1076KB
11ms
C839 bytes2023-04-09 10:50:46
854502022211306刘伟Output Limit Exceed
1076KB
12ms
C912 bytes2023-04-09 10:30:39
854252022211306刘伟Output Limit Exceed
1076KB
12ms
C822 bytes2023-04-09 09:42:45
854242022211306刘伟Output Limit Exceed
1076KB
11ms
C822 bytes2023-04-09 09:40:59
854222022211306刘伟Output Limit Exceed
1076KB
11ms
C828 bytes2023-04-09 09:37:24
854212022211306刘伟Compile Error
0KB
0ms
C902 bytes2023-04-09 09:36:39
854202022211306刘伟Compile Error
0KB
0ms
C910 bytes2023-04-09 09:35:24
807412022211306刘伟Accepted
1192KB
9ms
C1690 bytes2023-04-03 21:01:10
807292022211306刘伟Accepted
1204KB
10ms
C1389 bytes2023-04-03 20:56:21
766312022211306刘伟Wrong Answer
1192KB
9ms
C1690 bytes2023-03-31 19:08:18
726222022211306刘伟*Accepted64825
1200KB
13ms
C2908 bytes2023-03-29 11:40:04
726162022211306刘伟Wrong Answer
1192KB
9ms
C1691 bytes2023-03-29 11:33:14
726152022211306刘伟Wrong Answer
1192KB
11ms
C1691 bytes2023-03-29 11:32:55
726142022211306刘伟Wrong Answer
1192KB
9ms
C1688 bytes2023-03-29 11:32:34
713792022211306刘伟Accepted
1192KB
13ms
C1797 bytes2023-03-28 11:44:47
713782022211306刘伟*Accepted64826
1192KB
8ms
C2016 bytes2023-03-28 11:42:50
713762022211306刘伟Wrong Answer
1192KB
11ms
C1832 bytes2023-03-28 11:39:57
713712022211306刘伟Wrong Answer
1192KB
10ms
C1805 bytes2023-03-28 11:36:25
676362022211306刘伟Wrong Answer
1192KB
10ms
C1688 bytes2023-03-24 10:46:32
676252022211306刘伟Wrong Answer
1192KB
12ms
C1679 bytes2023-03-24 10:39:47
676132022211306刘伟*Accepted64610
1192KB
10ms
C2552 bytes2023-03-24 10:31:13
676072022211306刘伟Wrong Answer
1192KB
10ms
C1725 bytes2023-03-24 10:25:21
676022022211306刘伟Wrong Answer
1192KB
11ms
C1726 bytes2023-03-24 10:20:17