« [作業­2] 由檔案讀取成績並計算平均 - Perl 搜尋功能「檔案裡的字或片語」找不到的問題 »

三月17

[OOP] - 第一章作業­

tags | 1,362 views


功能說明:

輸入長及寬 => 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;
}
Trackback:

Leave a Reply