C++ PrimerPlus(第6版) P31 2.7 编程练习 题7
编写一个程序,要求用户输入小时数和分钟数。在main( )函数中,将这两个值传递给一个void函
数,后者以下面这样的格式显示这两个值:
Enter the number of hours: 9
Enter the number of minutes: 28
Time: 9:28
小编定义函数a()不严谨,也可根据喜好编辑(不要用到C++关键字)
#include <iostream>
using namespace std;
void a(int hours, int minutes)
{
cout << "Time: "
<< hours
<< ":"
<< minutes;
}
int main()
{
int hours = 0;
int minutes = 0;
cout << "Enter the number of hours :";
cin >> hours;
cout << "Enter the number of minutes :";
cin >> minutes;
a(hours, minutes);
return 0;
}