加起来除一下
然后四舍五入?反正这样过了
1 #include <iostream> 2 #include <cmath> 3 using namespace std; 4 int n; 5 double d,t; 6 int name,h; 7 char c[10]; 8 bool flag; 9 int main() 10 { 11 cin>>n>>d; 12 int cnt=0; 13 while(cin>>name) 14 { 15 t=0; 16 flag=1; 17 for(int i=1;i<=n;i++) 18 { 19 cin>>c; 20 if(c[0]=='-') flag=0; 21 if(flag) 22 { 23 t+=(c[0]-'0')*60*60; 24 t+=((c[2]-'0')*10+c[3]-'0')*60; 25 t+=((c[5]-'0')*10+c[6]-'0'); 26 } 27 } 28 if(!flag){ 29 printf("%3d: - ",name); 30 continue; 31 } 32 t=int((t/d)+0.5); 33 printf("%3d:%2d:%02d min/km ",name,(int)t/60,(int)t%60); 34 } 35 }