作者hankhank5345 (MPower)
看板C_and_CPP
標題[問題] C++ box
時間Fri Feb 27 09:31:49 2009
各位高手請問下面的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
1F:→ joefaq:參數不夠的你要自己弄預設值 02/27 10:17
2F:→ realmeat:welcome c++作業版 02/27 12:42
3F:→ hankhank5345:有人有碰過類似的題目嗎~~幫幫忙 02/27 13:26
4F:→ stonehomelaa:codejob版歡迎你 02/27 14:03
5F:→ windincloud:這篇我好像在別的論壇回複過~ XD 02/27 14:24