請問大神們 我錯在哪
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
ios::sync_with_stdio(0);
cin.tie(0);
int h1,m1,h2,m2,s1,s2,s3,s4;
while(cin>>h1>>m1>>h2>>m2){
if((h2>=h1)&&(m2>=m1)){
s1=(((h2-h1)*60)+(m2-m1));
cout <<s1 << "\n";
}else if((h2>h1)&&(m2<m1)){
s2=(((h2-h1)*60)-(m1-m2));
cout << s2 << "\n";
}else if( ( h2<h1 ) && ( m2>=m1 ) ){
s3=( ( ( (h2+24)-h1 ) * 60 ) + ( m2 - m1 ) );
cout << s3 << "\n";
}else if( ( h2>h1 ) && ( m2<m1 ) ){
s4=( ( ( ( h2+23 )-h1 ) * 60 ) + ( (m2+60) - m1 ) );
cout <<s4 << "\n";
}else if(h1==0 && h2==0 && m1==0 && m2==0){
break;
}
return 0;
}
}
請問大神們 我錯在哪
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
ios::sync_with_stdio(0);
cin.tie(0);
int h1,m1,h2,m2,s1,s2,s3,s4;
while(cin>>h1>>m1>>h2>>m2){
if((h2>=h1)&&(m2>=m1)){
s1=(((h2-h1)*60)+(m2-m1));
cout <
}else if((h2>h1)&&(m2<m1)){
s2=(((h2-h1)*60)-(m1-m2));
cout << s2 << "\n";
}else if( ( h2
=m1 ) ){
s3=( ( ( (h2+24)-h1 ) * 60 ) + ( m2 - m1 ) );
cout << s3 << "\n";
}else if( ( h2>h1 ) && ( m2
s4=( ( ( ( h2+23 )-h1 ) * 60 ) + ( (m2+60) - m1 ) );
cout <
}else if(h1==0 && h2==0 && m1==0 && m2==0){
break;
}
return 0;
}
}
檢查一下if吧,你很多種情況都會沒有輸出
檢查一下if吧,你很多種情況都會沒有輸出
而且你的return放錯地方了