vc++小案例:画方块

#include<iostream>
#include<Windows.h>

using namespace std;

/*
画方块
*/
int main(){
    int width=15;//方块宽度、长度
    int sleep_time=50;//休眠
    int i=0;
    for(;i<width;i++){

        cout << "-";
        Sleep(sleep_time);
    }
    cout<<endl;

    i=0;
    for(;i<width/2;i++){

        for(int j=0;j<width;j++){
            if(j==0){
                cout << "|";
            }else if(j==width-1){
                cout << "|";
            }else{
                cout << " ";
            }
            Sleep(sleep_time);
        }
        cout<<endl;

    }

    i=0;
    for(;i<width;i++){

        cout << "-";
        Sleep(sleep_time);
    }

    cout << endl;

}