1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
|
#include<iostream>
#include<iomanip>
using namespace std;
void convert(int, int&, int&, int&);
class Time
{
public:
int hour, minute, second;
Time(int h, int m, int s)
{
hour = h;
minute = m;
second = s;
}
void get()
{
cout << "Enter the time\n";
cout << "Hour: ";
cin >> hour;
cout << "Minutes: ";
cin >> minute;
cout << "Seconds: ";
cin >> second;
}
void show()
{
cout << setw(2) << setfill('0') << hour << ":" << setw(2) << setfill('0') << minute << ":" << setw(2) << setfill('0') << second << endl;
return;
}
void militaryTime(int h, int m)
{
int h1 = (h + 12);
cout << h1 << ":" << m;
return;
}
void standardTime(int h, int m)
{
cout << h << ":" << m;
return;
}
void changeTime(int h, int m, int s)
{
int h2 = (h + 2) < 12;
int m2 = (m + 12) < 60;
int s2 = (s + 1) < 60;
cout << h2 << ":" << m2 << ":" << s2;
return;
}
void convert(int totalsec, int& h, int& m, int& s)
{
s = totalsec % 60;
totalsec = totalsec / 60;
m = totalsec % 60;
h = (totalsec / 60) % 12;
if (h == 0)
h = 12;
return;
}
};
int main()
{
Time();
system("pause");
}
|