Jump to content

Recommended Posts

Posted

Boas , começei a programar em C este ano na Universidade e tenho que fazer uma trabalho tipo jogo da cobra etc etc . Optei por fazer um labirinto para ser diferente e tive a ver e na net so tem labirintos feitos sem um tabuleiro com uma certa dimensao. E queria uma opiniao de como fazer com o tabuleiro.

O tabuleiro esta aqui feito:

#include <stdio.h>
#define DIM 10
#define ESPACO ' '


void inic_tabuleiro (char s[] [DIM]) 
{
int i , j;
for (i = 0; i < DIM; i++)
	for (j = 0; j < DIM; j++)
		s[i][j] = ESPACO;
}  

void mostra_tabuleiro (char s[DIM][DIM]) 
{
int linha, coluna;
for (linha = 0; linha < DIM; linha++){
	printf ("|");
	for (coluna = 0; coluna < DIM; coluna++)
		printf ("%c %c", s[linha][coluna], coluna == DIM ? ' ': '|');				
			if (linha != DIM-1) 
				printf ("\n-------------------------------");
				putchar ('\n');

}

}

int main ()
{
	char Tabuleiro [DIM][DIM];


inic_tabuleiro (Tabuleiro);
mostra_tabuleiro (Tabuleiro);

return 0;
}

Cumps

Posted

Eu usaria uns sinais de "+" nos cruzamentos e uma linha completa tambem no principio e fim

+--+--+--+--+--+--+--+--+--+--+
|  |  |  |  |  |  |  |  |  |  |
+--+--+--+--+--+--+--+--+--+--+
|  |  |  |  |  |  |  |  |  |  |
+--+--+--+--+--+--+--+--+--+--+
|  |  |  |  |  |  |  |  |  |  |
+--+--+--+--+--+--+--+--+--+--+
|  |  |  |  |  |  |  |  |  |  |
+--+--+--+--+--+--+--+--+--+--+
|  |  |  |  |  |  |  |  |  |  |
+--+--+--+--+--+--+--+--+--+--+
|  |  |  |  |  |  |  |  |  |  |
+--+--+--+--+--+--+--+--+--+--+
|  |  |  |  |  |  |  |  |  |  |
+--+--+--+--+--+--+--+--+--+--+
|  |  |  |  |  |  |  |  |  |  |
+--+--+--+--+--+--+--+--+--+--+
|  |  |  |  |  |  |  |  |  |  |
+--+--+--+--+--+--+--+--+--+--+
|  |  |  |  |  |  |  |  |  |  |
+--+--+--+--+--+--+--+--+--+--+

What have you tried?

Não respondo a dúvidas por PM

A minha bola de cristal está para compor; deve ficar pronta para a semana.

Torna os teus tópicos mais atractivos e legíveis usando a tag CODE para colorir o código!

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.