【发布时间】:2018-04-16 18:58:38
【问题描述】:
我正在尝试用 Unicode 用 C++ 制作一个小 RPG,但我什至无法制作一个简单的盒子。我有以下代码
#include <iostream>
#include <string>
using namespace std;
void PrintLevel();
string lvl[5][4] {
{"\u250f", "\u2501", "\u2501", "\u2513"},
{"\u2503", "\u0020", "\u0020", "\u2503"},
{"\u2503", "\u0020", "\u0020", "\u2503"},
{"\u2503", "\u0020", "\u0020", "\u2503"},
{"\u2517", "\u2501", "\u2501", "\u251B"}
};
int main() {
PrintLevel();
}
void PrintLevel() {
for(int i = 0; i<5; i++) {
for(int j = 0; j<4; j++) {
cout << lvl[i][j];
if(j == 3) {
cout << "\n";
}
}
}
}
但它画了这个
我怎样才能让它画一个合适的盒子?
【问题讨论】:
-
不要使用stdio,因为它过于依赖终端渲染和用户选择的字体。
-
好像打印不错onlinegdb.com/B1h47uzhf
-
@Mgetz 我不是?
-
@KeineLust 它没有被编辑为使用
iostream,我一直使用它。 -
在终端中使用 monospace 字体。