[問題] C++ box
各位高手請問下面的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
02/27 12:42, 2F
→
02/27 13:26, , 3F
02/27 13:26, 3F
→
02/27 14:03, , 4F
02/27 14:03, 4F
→
02/27 14:24, , 5F
02/27 14:24, 5F
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章