【C++】打印方块并循环移动

效果展示 #include #include using namespace std;int main(){int w = 9, h = 9;int

效果展示
在这里插入图片描述

#include 
#include 
using namespace std;int main()
{int w = 9, h = 9;int mCurrent = 0;while (true){Sleep(100);system("cls");for (int i = 0; i < h; ++i){for (int j = 0; j < w; ++j){if (i * w + j == mCurrent){cout << "■";}else{cout << "□";}}cout << endl;}mCurrent++;if (mCurrent > w * h){mCurrent = 0;}}system("pause");return 0;
}