請不要直接抄寫程式碼! 也請不要直接跳到程式碼部分,除非你已經寫好了,想要參考別人的寫法!

#include <iostream>  
#include <sstream>  
using namespace std;  
int main()  
{  
    int hour,minute,second;  
    char symbol;  
    int priorTime,currentTime;  
    string time;  
    stringstream prior,current;  

    cin>>time;  
    prior<<time;  
    prior>>hour>>symbol>>minute>>symbol>>second;  
    priorTime = hour*3600 + minute*60 + second;  

    cin>>time;  
    current<<time;  
    current>>hour>>symbol>>minute>>symbol>>second;  
    currentTime = hour*3600 + minute*60 + second;  

    int delta = (currentTime - priorTime);  
    delta = ( delta/3600 > 0 ) ? ( delta%3600 > 0 ) ? delta/3600 : delta/3600-1 : 0 ;  
    cout<<delta*20<<endl;  
}

如果有任何問題,歡迎私訊跟我討論喔!