求助P8665
查看原帖
求助P8665
566249
kkkscp03楼主2022/11/12 18:55

为什么这段代码在本地上编译能通过,在洛谷测评机上编译失败?

提交记录

#include<bits/stdc++.h>
using namespace std;
int getTime(){
	char line[100]={};
	gets(line);
	int h1,m1,s1,h2,m2,s2,d=0;
	if(strlen(line)==17) sscanf(line,"%d:%d:%d %d:%d:%d",&h1,&m1,&s1,&h2,&m2,&s2); 
	else sscanf(line,"%d:%d:%d %d:%d:%d (+%d)",&h1,&m1,&s1,&h2,&m2,&s2,&d); 
	int time=(d*24*3600+h2*3600+m2*60+s2)-(h1*3600+m1*60+s1);
	return time;	
}
int main(){
	int n;
	scanf("%d",&n);
	getchar();
	while(n--){
		int time1=getTime();
		int time2=getTime();
		int t=(time1+time2)/2;
		printf("%02d:%02d:%02d\n",t/3600,t/60%60,t%60); 
	}
	return 0;
}

2022/11/12 18:55
加载中...