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 13:58:03
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
1024532022211327です*Accepted65033
1072KB
13ms
C1764 bytes2023-05-04 23:56:00
1024502022211327ですRuntime Error
10712KB
45ms
C1926 bytes2023-05-04 23:53:54
1024472022211327ですCompile Error
0KB
0ms
C1743 bytes2023-05-04 23:52:16
1024382022211327ですWrong Answer
1068KB
11ms
C1938 bytes2023-05-04 23:47:38
1024292022211327です*Accepted64825
1200KB
12ms
C2345 bytes2023-05-04 23:43:38
1024092022211327です*Accepted65047
1196KB
12ms
C2935 bytes2023-05-04 23:35:10
1024072022211327ですRuntime Error
1068KB
9ms
C1760 bytes2023-05-04 23:33:53
1024062022211327ですCompile Error
0KB
0ms
C1759 bytes2023-05-04 23:33:23
1023992022211327ですRuntime Error
1068KB
11ms
C1782 bytes2023-05-04 23:29:38
1021152022211327ですWrong Answer
1068KB
11ms
C1183 bytes2023-05-04 20:25:06
1021142022211327ですWrong Answer
1192KB
11ms
C876 bytes2023-05-04 20:24:37
1021002022211327ですRuntime Error
1192KB
11ms
C1705 bytes2023-05-04 20:03:06
1020412022211327ですRuntime Error
1192KB
12ms
C1483 bytes2023-05-04 17:44:36
1020342022211327ですRuntime Error
1192KB
9ms
C1506 bytes2023-05-04 17:26:19
1018512022211327です*Accepted64826
1192KB
11ms
C1552 bytes2023-05-04 12:20:40
1018502022211327ですOutput Limit Exceed
1200KB
11ms
C2199 bytes2023-05-04 12:00:30
996342022211327ですTime Limit Exceed
1200KB
5287ms
C2009 bytes2023-05-01 18:34:40
996332022211327ですTime Limit Exceed
1192KB
5283ms
C2007 bytes2023-05-01 18:30:24
996282022211327ですTime Limit Exceed
1192KB
5285ms
C2012 bytes2023-05-01 18:25:39
996252022211327ですTime Limit Exceed
1192KB
5286ms
C1970 bytes2023-05-01 18:23:16
996222022211327ですCompile Error
0KB
0ms
C1973 bytes2023-05-01 18:20:23
996202022211327ですCompile Error
0KB
0ms
C1961 bytes2023-05-01 18:19:07