Untitled

 avatar
unknown
plain_text
3 years ago
1.2 kB
4
Indexable
#include <iostream>
#include <math.h>
using namespace std;
struct Time{
	int hours;
	int minutes;
	int seconds;
};
int main() {
	int a, b, c, d, e, f;
	setlocale(LC_ALL, "Russian");
	Time time1;
	Time time2;
	Time time3;
	cout << "Введите первое время (часы минуты и секунды через пробел) \n";
	cin >> time1.hours;
	cin >> time1.minutes;
	cin >> time1.seconds;
	cout << "Всего " << time1.hours * 3600 + time1.minutes * 60 + time1.seconds << " секунд" << "\n";
	a = time1.hours * 3600 + time1.minutes * 60 + time1.seconds;
	cout << "Введите второе время (часы минуты и секунды через пробел) \n";
	cin >> time2.hours;
	cin >> time2.minutes;
	cin >> time2.seconds;
	cout << "Всего " << time2.hours * 3600 + time2.minutes * 60 + time2.seconds << " секунд" << "\n";
	b = time2.hours * 3600 + time2.minutes * 60 + time2.seconds;
	c = abs(a - b);
	d = c % 60;
	e = c / 60;
	f = e / 60;
	cout << "Разница : " << c << " Секунд(" << f << " Часов " << e - f * 60 << " Минут " << d << " Секунд)";
}
Editor is loading...