我剛剛開始閱讀C++教科書,並且在解決本章末尾的一個編碼問題時遇到了問題。這裏是問題:打印時間到std :: ostream
編寫一個程序,要求用戶輸入小時值和分鐘值。然後將 main()函數應該這兩個值傳遞給在下面的示例運行中所示的格式顯示 兩個值的類型void函數:
輸入的小時數:9
輸入的數分:28
時間:9:28
到目前爲止我的代碼是:
#include <iostream>
using namespace std;
void time(int h, int m);
int main()
{
int hour, min;
cout << "enter the number of hours: ";
cin >> hour;
cout << "enter the number of minutes: ";
cin >> min;
string temp = time(hour, min);
cout << temp;
return 0;
}
void time(int h, int m)
{
string clock;
clock =
}
什麼我現在做time(n, m)
函數內?
謝謝。
http://www.cplusplus。com/reference/clibrary/cstdio/printf/ – 2012-02-08 21:17:59
請不要同時添加printfs和cout。堅持一個,最好在c + + – jglouie 2012-02-08 21:20:29