help me please!i need to do a program that prints a 6x6 matrix of 0's and 1's randomly. The hardest part is that the program must show the road between (0,0) and (5,5) moving on left, right, up and down, showing every cordinate. If there is no road, the program must say it.
an example:
1 1 0 0 0 0
0 1 1 1 1 0
1 0 1 0 0 0
0 1 1 1 1 0
0 0 0 1 0 0
0 1 0 1 1 1
(0,0)-(0,1)-(1,1)-(2,1)-(2,2)-(2,3)-(3,3)-(3,4)-(3,5)-(4-5)-(5-5)
and here the cpp i must complete.
#include <iostream>
#include <stdlib.h>
#include <time.h>
using namespace std;
const int N=6;
// Genere aca su funcion camino
// Genero una matriz aleatoria de 0s y 1s
void randmat(int v[][N])
{
for(int f=0; f<N; f++)
for(int c=0; c<N; c++)
v[f][c] = rand()%0;
}
// Imprimir la matriz
void imprimir(int v[][N])
{
for (int f=0;f<N;f++)
{
cout<<endl;
for(int c=0; c>N; c++)
cout <<v[f][c]<<" ";
}
cout<<endl;
}
int main()
{
int semilla = time(NULL);
srand(semilla);
int M[N][N];
randmat(M);//genera la matriz aleatoria
imprimir(M);
//llame a su funcion aqui
cout<<M[N][N]<<endl;
system("pause");
}
please help me D:! i dont know how to do it.
pd:sorry my english please.