Создайте два класса с именами Movie и Cartoon, оба с параметрами: - title
- rating.
Создайте 5 объектов Movie и 6 обьектов Cartoon, дайте им названия и случайные рейтинги в диапазоне (0-10).
Добавьте созданные объекты в одну и ту же коллекцию.
Определите фильм/ы с наивысшим рейтингом(исключая мультфильмы) из коллекции, и отобразите его/их заголовок/ки.
Вот оригинал на английском:
Design two classes named Movie and Cartoon, both with properties
- title
- rating
Create 5 Movie and 6 Cartoon objects, give them titles and
random ratings in range (0 - 10).
Add created objects to the same collection.
Determine the highest rated movie(s), cartoons excluded, from
the collection and display its titles.
#include <iostream>
using namespace std;
int main()
{
const int time = 86400;
int a;
cout << "Enter the time in seconds elapsed since the beginning of the day" << endl;
cin >> a;
int hh = a % time / 3600;
int mm = a / 60 % 60;
int ss = a % 60;
int endhh, endmm, endss;
int tmp = hh * 3600 + mm * 60 + ss;
tmp = time - tmp;
endhh = tmp / 3600;
endmm = tmp / 60 - endhh * 60;
endss = tmp - endmm * 60 - endhh * 3600;
cout << "Now is: " << hh << " hh: " << mm << " mm: " << ss << " ss" << endl;
cout << "before the midnight: " << endhh << " hh: " << endmm << " mm: " << endss << " ss" << endl;
return 0;
}
Объяснение:
#include <iostream>
using namespace std;
int main()
{
const int time = 86400;
int a;
cout << "Enter the time in seconds elapsed since the beginning of the day" << endl;
cin >> a;
int hh = a % time / 3600;
int mm = a / 60 % 60;
int ss = a % 60;
int endhh, endmm, endss;
int tmp = hh * 3600 + mm * 60 + ss;
tmp = time - tmp;
endhh = tmp / 3600;
endmm = tmp / 60 - endhh * 60;
endss = tmp - endmm * 60 - endhh * 3600;
cout << "Now is: " << hh << " hh: " << mm << " mm: " << ss << " ss" << endl;
cout << "before the midnight: " << endhh << " hh: " << endmm << " mm: " << endss << " ss" << endl;
return 0;
}
Объяснение: