三月17
[OOP] - 第一章作業
->
功能說明:
輸入長及寬 => 10 7
輸入邊框及填充字元 => C +
執行結果:
CCCCCCCCCC
C++++++++C
C++++++++C
C++++++++C
C++++++++C
C++++++++C
CCCCCCCCCC
程式實作:
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int width, height;
char border, inner;
cout << "Enter Width and Height => ";
cin >> width >> height;
cout << "Enter Border and Inner character => ";
cin >> border >> inner;
for (int i=1; i<=height; i++)
{
if (i==1 || i==height)
cout << setw(width) << setfill(border) << border << endl;
else
cout << border << setw(width-1) << setfill(inner) << border << endl;
}
system("PAUSE");
return 0;
}
#include <iomanip>
using namespace std;
int main()
{
int width, height;
char border, inner;
cout << "Enter Width and Height => ";
cin >> width >> height;
cout << "Enter Border and Inner character => ";
cin >> border >> inner;
for (int i=1; i<=height; i++)
{
if (i==1 || i==height)
cout << setw(width) << setfill(border) << border << endl;
else
cout << border << setw(width-1) << setfill(inner) << border << endl;
}
system("PAUSE");
return 0;
}


近期留言