[求助]C++问题2
编写一个程序,要求用户输入小时数和分钟数.在main()函数中,将两个值传递给一个void函数,后者以下面这样的格式显示这两个值:Enter number of hours:9
Enter number of minutes:28
Time: 9:28
下面是我用VC++2005编写的.
#include <iostream>
using namespace std;
void time(int);
int main()
{
cout <<"Enter the number of hours: ";
int hour;
cin >>hour;
cout <<"Enter the number of minutes: ";
int minute;
cin >>minute;
int n;
time(n);
cin.get();
cin.get();
return 0;
}
void time(int n)
{
int hour;
int minute;
hour:minute=n;
cout <<"Time : "<<n<<endl;
}
警告 1 warning C4700: 使用了未初始化的局部变量“n” e:\microsoft visual studio 2005 简体中文专业版\vc++2005\my6\my6\my6.cpp 13
可是出来的是
Enter number of hours:9
Enter number of minutes:28
Time:-858993460
请各位大哥帮帮忙!
[此贴子已经被作者于2007-5-14 15:57:57编辑过]