#include <iostream>
using namespace std;
void time(int h,int m)
{
cout<<"Time: "<<h<<":"<<m<<endl;
}
int main()
{
cout<<"Enter the number of hours: ";
int i,j;
cin>>i;
cout<<"Enter the number of hours: ";
cin>>j;
time(i,j);
return 0;
}
本文介绍了一个使用C++编写的简单程序,该程序通过用户输入小时和分钟来显示时间。程序利用了<iostream>库,并使用了标准命名空间std。通过定义一个名为time的函数来实现时间的格式化输出。
#include <iostream>
using namespace std;
void time(int h,int m)
{
cout<<"Time: "<<h<<":"<<m<<endl;
}
int main()
{
cout<<"Enter the number of hours: ";
int i,j;
cin>>i;
cout<<"Enter the number of hours: ";
cin>>j;
time(i,j);
return 0;
}
1785
1万+

被折叠的 条评论
为什么被折叠?