Hello, I am a non-cs student who has not really had any prior experience with C++ besides coding up a few simple programs on my own time.
I am trying to implement the A* pathfinding algorithm and I have all of the logic figured out and written down in pseudo-code, but the implementation has got me banging my head against the wall. I just spent the last 40 minutes searching these forums and google, but I can't seem to find the answer to my question on what syntax do I use to declare a matrix?
I am trying to hardcode a 5x5 matrix that will store values which I define.
Here is my code that I have written, but I know this isn't right because I tried to compile this in terminal and I got a whole lot of errors:
#include "math.h"
#include <iostream>
using namespace std;
int main()
{
double distance[][] = 0;
int x = 5;
int y = 5;
//set the matrix to be 5x5 and assign every element to be 0
distance[x][y] = 0;
//view matrix in terminal
cout << distance << endl;
return 0;
}
Could someone also tell me how to access/assign elements in a matrix correctly, or just direct me to an article that goes over the syntax on how to do this?
Also, another nooby question, but I was wondering how to compile and run this code in linux properly.
I type: g++ astartest.cc
then I see an a.out file in my folder and I try to type gcc a.out and ./a.out but neither work properly.
I know that this is really simple stuff, but I tried looking around for it and just found a lot of articles/threads that seem above my level since everyone knows how to declare matrices.... :P
Thanks a lot to anyone that decides to help!