助けてください!0 と 1 の 6x6 マトリックスをランダムに出力するプログラムを実行する必要があります。最も難しい部分は、プログラムが (0,0) と (5,5) の間の道路を左、右、上、下に移動し、すべての座標を表示する必要があることです。道がない場合、プログラムはそれを言わなければなりません。
例:
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)
ここで、cpp を完了する必要があります。
#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");
}
助けてください D:! 私はそれを行う方法を知りません。
pd:すみません、英語でお願いします。