读书人

请问一道题目的答案

发布时间: 2012-02-11 09:51:34 作者: rapoo

请教一道题目的答案!
我是个新手在学C++,课后有个题目不知道怎么做,请各位帮忙解答下。

编写一个程序,要求用户输入小时数和分钟数,在main()函数中,将这两个值传递给一个void函数,后者以下面这样的格式显示这2个值;
Enter the number of hours: 9
Enter the number of minutes: 28
Time: 9:28



我不知怎么去定义一个void的函数显示以上的内容!!各位帮忙解答下,感激不尽啊!!

[解决办法]

C/C++ code
#include <iostream>using namespace std;void show(int h,int m){    cout << "Time:"<< h << ":" << m ;}int main(){    int h,m;    cout << "Enter the number of hours:";    cin >> h;    cout << "Enter the number of minutes:";    cin >> m;        show(h,m);} 

读书人网 >C++

热点推荐