小编Mat*_*ler的帖子

通过2d数组迭代和输出?

我正在尝试编写"Conways Game of Life"可视化.我觉得我对如何去了解它,但我的问题,我遇到了这是一个坚实的想法:当我试图输出行和我的二维数组的列,它开始接近尾声数字之间跳跃,它从不停止滚动数字.它似乎陷入78的"x".

#include <iostream>
#include <cstring>
#include <cstdlib>
#define HEIGHT 25
#define WIDTH 80
using namespace std;

void makeBoard();
int seed = 0;

int main()
{
    makeBoard();
}

void makeBoard()
{
    int board[79][24] = {0};
    /* Seed the random number generator with the specified seed */
    srand(seed);
    for(int x = 0; x <= 79; x++)
    {
        for(int y = 0; y <= 24; y++)
        {
            /* 50% chance for a cell to be alive */
            if(rand() % 100 …
Run Code Online (Sandbox Code Playgroud)

c++ arrays

2
推荐指数
1
解决办法
71
查看次数

退出后代码崩溃了?

无论出于何种原因,我的代码崩溃了,但只有在退出程序之后(通过点击"X"),任何人都知道它为什么这样做?这是我的代码.

#include <iostream>
#include <cstring>
#include <cstdlib>
#include <windows.h>
#include <time.h>


#include <SDL/SDL.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glext.h>
using namespace std;

/*
const int AIR = 0;
const int STONE = 1;
const int DIRT = 3;
const int GRASS = 4;
*/


float SCALE = .5;
const int chunkSize = 16;
const int chunkSizeY = 256;
const int blocksTotal = 4;
int chunk[chunkSize][chunkSizeY][chunkSize];
time_t seconds;
int seed = 0;
int quads;

struct block {
  bool Solid;
  int DepthMAX; …
Run Code Online (Sandbox Code Playgroud)

c++ arrays crash struct

-2
推荐指数
1
解决办法
72
查看次数

标签 统计

arrays ×2

c++ ×2

crash ×1

struct ×1