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
|
#include <iostream>
void input(int hours, int minutes);
void output(int hours2, int minutes, std::string thing);
void compute(int hours, int minutes, std::string thing, int hours2);
using namespace std;
int main()
{
std::string thing;
int hours, minutes, hours2;
input(hours, minutes);
compute(hours, minutes, thing, hours2);
output(hours2, minutes, thing);
return 0;
}
void input(int hours, int minutes)
{
cout << "Enter the time in hours." << endl;
cin >> hours;
cout << "Enter the time in minutes." << endl;
cin >> minutes;
}
void compute(int hours, int minutes, std::string thing, int hours2)
{
if (hours > 12)
hours2 = hours - 12;
else
hours2 = hours;
if (hours > 11)
thing = "PM";
else
thing = "AM";
}
void output(int hours2, int minutes, std::string thing)
{
cout << hours2 << ":" << minutes << " " << thing;
}
|