[問題] C++ box

看板C_and_CPP (C/C++)作者 (MPower)時間16年前 (2009/02/27 09:31), 編輯推噓0(005)
留言5則, 5人參與, 最新討論串1/1
各位高手請問下面的Function definition該如何寫.幫幫忙 謝謝 題目: Ooverload displayBox function – uses loops Complete the program template box.cpp Use input data of: 5 ? 15 4 $ NOTE: Only one of your overloaded functions needs the details of nested loops. The other 3 SHOULD call the one that has the details. NOTE: displayBox(5) is: XXXXX displayBox(5,'?') is XXXXX X X X???X X X X???X X X X???X XXXXX XXXXX Ans: #include <iostream> using namespace::std; void displayBox ( int length ); void displayBox ( int length, char fillChar ); void displayBox ( int width, int height ); void displayBox ( int width, int height, char FillChar ); int main() { int boxLength, boxWidth, boxHeight; char boxFill; cout << endl << "Enter the length of a side: "; cin >> boxLength; displayBox(boxLength); cout << endl << "Enter the fill character: "; cin >> boxFill; displayBox(boxLength,boxFill); cout << endl << "Enter the width and height of the box: "; cin >> boxWidth >> boxHeight; displayBox(boxWidth,boxHeight); cout << endl << "Enter the fill character: "; cin >> boxFill; displayBox(boxWidth,boxHeight,boxFill); return 0; } void displayBox ( int length ) { } void displayBox ( int length, char fillChar ) { } void displayBox ( int width, int height) { } void displayBox ( int width, int height, char FillChar ) { } -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 71.199.79.106

02/27 10:17, , 1F
參數不夠的你要自己弄預設值
02/27 10:17, 1F

02/27 12:42, , 2F
welcome c++作業版
02/27 12:42, 2F

02/27 13:26, , 3F
有人有碰過類似的題目嗎~~幫幫忙
02/27 13:26, 3F

02/27 14:03, , 4F
codejob版歡迎你
02/27 14:03, 4F

02/27 14:24, , 5F
這篇我好像在別的論壇回複過~ XD
02/27 14:24, 5F
文章代碼(AID): #19fqA6PU (C_and_CPP)
文章代碼(AID): #19fqA6PU (C_and_CPP)