请教C++程序!

来源:百度知道 编辑:UC知道 时间:2024/05/28 18:10:48
我是新手 再看《C++ Primer Plus》中文版(第五版)时 由于没有编程题的答案 自己是在弄不出来了 请给位帮忙 给我这道题的代码
题目如下
要求用户输入小时和分钟,在main()函数中 将这两个值传给一个 void函数 后者 以这样格式显示这两个值
enter the number of hours :7
enter the number of minutes :25
time:7:25
请给个新手能看得懂 较为详尽的代码!!!
谢谢

#include<iostream>
using namespace std;
void void(int hour,int minute)
{
cout<<"time:"<<hour<<":"<<minute<<endl;
}
void main()
{
int hour,minute;
cout<<"enter the number of hours :";
cin>>hour;
cout<<"enter the number of minutes :;
cin>>minute;
void(hour,minute);
}

输入 小时:分钟即可
#include <stdio.h>
void time(int h,int m)
{
printf("enter the number of hours:%d\n",h);
printf("enter the number of hours:%d\n",m);
printf("time:%d:%d\n",h,m);
}
int main()
{
int h,m;
printf("Please enter the time:\n");
scanf("%d:%d",&h,&m);
time(h,m);
return 0;
}

csdn里有答案下载,到那里现在把...