int h1, h2, m1, m2, h, m;
do
{
cout << "Enter input {Hour minute} 1 : ";
cin >> h1 >> m1;
} while (h1<1 || h1>12 || m1<0 || m1>60);
do
{
cout << "Enter input {Hour minute} 2 : ";
cin >> h2 >> m2;
} while (h2<1 || h2>12 || m2<0 || m2>60);
h = abs(h2 - h1);
m = (m2 - m1);
if (m<0)
{
m = 60 + m;
h = h - 1;
}
cout << h << ":" << m << endl;
ไม่มีความคิดเห็น:
แสดงความคิดเห็น