我试着用它.这对于一些Plots来说真的很不错,但是当它以三角形为例时我发现它非常复杂.我想出了如何绘制三角形,但如何添加角度标记,那些曲线?
因为我刚开始从事这项工作,写一本书,任何人都可以推荐我,这是获得好看图形的最佳方法,例如如下图所示.哪种程序最好用.
感谢您提出任何建议和意见.
输入:由任意大小的bool矩阵表示的迷宫.(超出范围计为0)
00100
00100
01110
11111
01110
00100
Run Code Online (Sandbox Code Playgroud)
输出:迷宫的漂亮表示(邻域被映射到a wchar_t
):
???
?1?
??1??
??111??
|11111|
??111??
??1??
???
Run Code Online (Sandbox Code Playgroud)
编辑:基本上每个0都被映射到表示墙布局的4位值.
我的方法和想法:
我认为一次看每个细胞最简单.然后看看它的邻居来确定放在那里的价值.结果我有8个布尔输入(所有邻居),这产生2 ^ 8 = 256个不同的场景.我不觉得他们都很难编码.
是否有更优雅的方法来正确映射值?
在过去的一周里,我和朋友一起用C++ 编写了一个roguelike游戏.大部分也学习语言.
我正在使用:
wchar_t
在控制台中输出我想要的任何地方.我成功输出了一些unicode字符,如\ u263B(☻),但其他如\ u2638(☸)最终会以问号(?)结束.
这是我用于输出的相关代码.
// Container of room information
struct RoomInfo
{
wchar_t * layout;
int width;
int height;
};
// The following function builds RoomInfo
RoomInfo Room::examine(IActor * examinor)
{
RoomInfo ri;
ri.width = this->width;
ri.height = this->height;
ri.layout = new wchar_t[height * width];
for(unsigned int y = 0; y < height; y++)
{
for(unsigned int x = 0; x < width; x++)
{
ri.layout[y*width + x] …
Run Code Online (Sandbox Code Playgroud) 场景:我有以下定义的类.
class Baseclass { };
class DerivedTypeA : public Baseclass { };
class DerivedTypeB : public Baseclass { };
// ... and so on ...
class Container
{
list<Baseclass*> stuff;
list<DerivedTypeA*> specific_stuff;
// ... initializing constructors and so on ...
public:
void add(Baseclass * b)
{
stuff.add(b);
}
void add(DerivedTypeA * a)
{
stuff.add(a);
specific_stuff.add(a);
}
};
class ContainerOperator
{
Container c;
// ... initializing constructors and so on ...
public:
void operateOnStuff(Baseclass * b)
{
// This will …
Run Code Online (Sandbox Code Playgroud) 我正在尝试编写一些代码,这些代码使用管道在父进程和它的子进程之间进行通信.但是,我的管道在我第一次使用它之后似乎放弃了(也就是说,它在第一次使用管道后停止工作).我不确定如何解决这个问题,任何帮助将不胜感激.我也知道我在这里使用的一些编码实践并不是很理想(主要是使用睡眠).
const int READ = 0;
const int WRITE = 1;
char* COOP = "Criminal cooperates\n";
char* SIL = "Criminal doesn't talk\n";
char* reader(int);
void writer(int, char *c);
int main()
{
int c1pipe1[2];
int c1pipe2[2];
int c2pipe1[2];
int c2pipe2[2];
int c1sentence = 0;
int c2sentence = 0;
int r;
int c;
pipe(c1pipe1);
pipe(c1pipe2);
pipe(c2pipe1);
pipe(c2pipe2);
int C2;
int C1 = fork();
if(C1 > 0)
C2 = fork();
if(C1 < 0 || C2 < 0) //error
{
perror("fork() failed");
exit(1);
} …
Run Code Online (Sandbox Code Playgroud)