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:24:38
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
981602022211358wwwAccepted
1068KB
11ms
C1066 bytes2023-04-30 13:51:53
974532022211358wwwOutput Limit Exceed
1068KB
11ms
C1055 bytes2023-04-29 16:29:34
974372022211358wwwRuntime Error
1068KB
10ms
C1054 bytes2023-04-29 16:18:27
974272022211358wwwOutput Limit Exceed
1068KB
11ms
C1040 bytes2023-04-29 16:11:01
974232022211358wwwRuntime Error
1068KB
12ms
C1038 bytes2023-04-29 16:07:15
974012022211358wwwOutput Limit Exceed
1068KB
11ms
C923 bytes2023-04-29 15:24:06
974002022211358wwwOutput Limit Exceed
1068KB
13ms
C922 bytes2023-04-29 15:23:09
973982022211358wwwOutput Limit Exceed
1068KB
10ms
C906 bytes2023-04-29 15:16:34
973912022211358wwwOutput Limit Exceed
1068KB
9ms
C917 bytes2023-04-29 15:13:09
973872022211358wwwOutput Limit Exceed
1068KB
10ms
C900 bytes2023-04-29 15:08:42
973822022211358wwwOutput Limit Exceed
1068KB
12ms
C894 bytes2023-04-29 15:04:01
973202022211358wwwAccepted
1192KB
13ms
C1829 bytes2023-04-29 13:44:48
972902022211358wwwWrong Answer
1192KB
12ms
C1848 bytes2023-04-29 13:19:28
901172022211358wwwTime Limit Exceed
1192KB
5275ms
C1782 bytes2023-04-17 17:08:40
901062022211358wwwTime Limit Exceed
1192KB
5285ms
C1779 bytes2023-04-17 16:35:42
896862022211358wwwAccepted
1196KB
11ms
C2117 bytes2023-04-16 19:48:22
896832022211358wwwRuntime Error
1200KB
11ms
C2117 bytes2023-04-16 19:44:17
896762022211358wwwOutput Limit Exceed
1196KB
11ms
C1920 bytes2023-04-16 19:32:31
896752022211358wwwOutput Limit Exceed
1196KB
11ms
C1915 bytes2023-04-16 19:30:57
882152022211358wwwRuntime Error
1200KB
8ms
C1985 bytes2023-04-13 11:44:26
881682022211358wwwOutput Limit Exceed
1196KB
11ms
C1900 bytes2023-04-13 11:09:12
850552022211358wwwRuntime Error
1196KB
10ms
C1726 bytes2023-04-08 17:16:44
849822022211358wwwRuntime Error
1196KB
9ms
C1656 bytes2023-04-08 16:29:25
849642022211358wwwRuntime Error
1192KB
9ms
C1525 bytes2023-04-08 16:13:19
849622022211358wwwCompile Error
0KB
0ms
C1528 bytes2023-04-08 16:11:47
849472022211358wwwRuntime Error
1192KB
9ms
C1496 bytes2023-04-08 15:51:37
849432022211358wwwRuntime Error
1192KB
10ms
C1524 bytes2023-04-08 15:44:48
835342022211358wwwAccepted
1192KB
12ms
C1704 bytes2023-04-05 23:21:47
835172022211358wwwWrong Answer
1192KB
12ms
C1675 bytes2023-04-05 23:09:49
833582022211358wwwWrong Answer
1192KB
13ms
C1666 bytes2023-04-05 22:03:56