An array which stores values with 2 indices

learn more… | top users | synonyms

-1
votes
0answers
24 views

Permutations using a 2D array

I need to write a short program that is able to output the permutations of the input which can be one of the following integers: 1, 2, 3, 4, 5 or 6. I need to store the permutations of in a 2D array ...
0
votes
0answers
14 views

2d arrays board game-limiting to only move per turn (java)

So in a 2d array of pieces called board that is an 8 x 8 checkers board. Let's say there's a method that returns void called pieceMove which takes parameters of int currentColumn, int currentRow, int ...
0
votes
1answer
60 views

if-else statements and 2d arrays

I am writing a method that checks to see if certain moves of a checkers game are valid by returning true or false. My code works fine when I want to move diagonally (not jumping). However, when I try ...
0
votes
1answer
20 views

Replacing specific values in 2D array

I have a file that contains these values: 0 0 0 0 0 0 0 0 0 The 2D array is loaded by the following code: string Seats[10][10]; // creates array to hold strings short loop1 = 0; //short for ...
0
votes
1answer
7 views

How to use equals method in java using instanceof for 2d arrays?

/I am trying to write an equals method using instanceof for 2d arrays (board is a Chess field that holds a 2d array of Piece). I think I got most of it but I'm stuck trying to write the last part. ...
2
votes
1answer
35 views

Array 2D to 1D conversion and confusion

I am confused to convert a 2D array into 1D array. I want to write a neighboring 8 elements for "a11" (which is at (1,1)) in the form of width ,rows and cols format without using for loop. ...
1
vote
3answers
41 views

Is it possible to create a 2D jagged array of a generic type in Java?

Is it possible to create an two-dimensional array of a generic type parameter with only a size specified in Java? To illustrate, can we create an array like this: T[][] array = new T[x][];
0
votes
4answers
42 views

Using list comprehension to search a 2d array (python)

I am trying to search a 2D array of characters and return the array indices, (x_T,y_T), of all of the letter T's in the array. I figure this could easily done with two stacked for loops but I was ...
0
votes
1answer
31 views

Populating a 2D array of objects using given probability in Java

I have been given a task to create a program which models cell growth according to some given rules. To do this, I have to create a 2D array and populate it with Cell objects which are either living ...
0
votes
1answer
47 views

Passing variable defining the size of a 2D array's elements

I'm working on some passing of arrays in C++. The following works, provided I define the array with numbers such as: gen0[6][7]. But, I cannot call the method where I send a variable as my size ...
0
votes
2answers
26 views

How to transfer a char * into a 2d char array

I am trying to take a char *, which represents a single word and i got the char * from a function, and put it into a 2d array but instead it just repeats the first letter of each word several times. ...
0
votes
1answer
35 views

Generate all paths/routes through 2D array in Java

I'm working in Java. Given a matrix NxM, I need to find all possible paths through the array. It is only allowed to go diagonally up or down, or go to the right. An example 4x4 matrix: 3 5 7 9 2 ...
-2
votes
2answers
42 views

How to stop char variables from being overwritten? [closed]

Im making a 2 player tic tac toe game in C++ and Im currently fixing a couple a problems I had with it. So the program is complete except for 1 tiny detail, players can overwrite the other players ...
0
votes
1answer
42 views

Setup a 2D array, change size later - C

Is it possible to declare a 2D array in C, then set its size later on? I know in C you have to deal with memory and such, but I cannot find answer to this question despite all my searching. My ...
0
votes
1answer
51 views

Best practices for working with 2d arrays in clojure?

I am building a minesweeper where the gameboard is a 2d array. To generate the board I need to get a 2d array, randomly place some bombs, calculate all neighboring bombs for each field, then pack all ...
-1
votes
2answers
34 views

java.lang.nullpointer exception in a for loop

I am trying to make a schedule which takes inputs from the user using the Scanner class. The point of the program is to print out the schedule. In the for loop in the makeSchedule function, there ...
0
votes
0answers
17 views

Python 2-D array changing one element changes whole column [duplicate]

So I'm working with 2-D int arrays, and somehow changing a single element changes the whole column. What's going on? >>> a = [[0]*3]*3 >>> a [[0, 0, 0], [0, 0, 0], [0, 0, 0]] ...
0
votes
1answer
44 views

How to find the index of element in two dimensional hash

I have a 2D array containing names and dates: name_date_array = [[John Doe, 8/9/14], [Jane Smith, 9/4/14], [Mary Jane, 6/5/14], [John Doe, 5/2/14]] (I am rewriting this as it was unclear) I have ...
-3
votes
0answers
38 views

Read text file in single character of 2D array

I am quite new in java. I am trying to read a text file. The file look like this: 195, 2829, 2864 135, 2974, 4950, 5061, 5138, 5139, 5140, 5141 120, 270, 614, 668, 692, 716, 1546, 1865, 2431, 2618, ...
-1
votes
1answer
42 views

Java Reversi/Othello Program 2D array flip/get methods?

I'm hoping someone could help me understand my code probs. I'm trying to create a Reversi board game in Java but my game board will only stick to white pieces and refuse to do anything. Any ...
1
vote
2answers
58 views

C++ Compiler Error: “No matching function for call”, when using a 2-D array as an argument

I'm trying to call a function (called closestPair) in a separate .cpp file from my main.cpp, using a [5][10] 2D-array as an argument. The call: extern const unsigned int vSize = 10; [...] double ...
0
votes
1answer
25 views

multidimensional array initialization using pointers

I want to have a function which initializes dynamic 2d arrays in cpp like below void initArrays(int n,double **a,double **b,double **c) { a = new double*[n]; for (int i = 0; i < n; i++) a[i] = ...
0
votes
4answers
59 views

How to skip first element in each line of matrix?

I have next matrix: 1 4 2 1 3 5 2 3 1 2 4 5 3 4 5 3 2 1 4 5 1 3 4 2 5 3 2 4 5 1 and I am writing it from text file to 2d array starting from second line in file in this cycle: foreach (var line in ...
-3
votes
1answer
33 views

how do i add up values in 2d arrays?

So i want to create a program that will print true or false depending on the values of the array. If the values in the 2d array (row and column) each equal 15. so the values in the row equal 15 and ...
0
votes
2answers
28 views

how do i get the mode of a 2d array

I was wondering how to get the mode of a 2d array in java. What are some different ways I could approach the problem? So far here is my code for the method. EDIT: Also, i forgot to mention that the ...
2
votes
1answer
37 views

Allocating 2D array with pointer to fixed-size array

Is it valid in C to dynamically allocate 2d arrays this way? //fixed size int (*arr2d)[9][9]=malloc(sizeof(int[9][9])); //variable size int x=5,y=3; int (*arr2d)[x][y]=malloc(sizeof(int[x][y])); ...
-1
votes
0answers
28 views

Java search 2D array of chars for a sequence which is a string

I'm creating a word search program. This word search program has a 2D Char array. It also has an array of Strings to search for within the array. Currently, I'm working on a test case where it only ...
0
votes
1answer
40 views

2D Array outputting from left to right, then right to left. Can't seem to get the correct element

I have to output my 2D Array from left to right on even rows, and from right to left on odd rows. I've done that and that isn't the problem. The problem is I am getting really confused when I try to ...
-2
votes
0answers
41 views

Use a 2d array to display a chessboard

The eight queens puzzle is the problem of placing eight chess queens on an 8×8 chessboard so that no two queens threaten each other. Remember queens can capture pieces by moving any number of ...
0
votes
2answers
35 views

2D Array output 'back and forth' effect

I am trying to make my 2D array output so that every second line outputs from right to left. For instance just outputting normally would look like this: 0.5 0.62 0.35 0.6 0.5 ...
0
votes
1answer
28 views

invalid use of non-static data member error with template friend functions c++

#include <cassert> #include <iostream> #include <iostream> #include <fstream> #include <string> #include <iomanip> using namespace std; template <class T> ...
0
votes
1answer
42 views

Pass a 2d array to a function

I deal with graphs more often than not and find it difficult to pass the adjacency list to a function. void myfunc(int ad[][])//proper way to receive it? { } int main() { int N;//number of ...
1
vote
4answers
37 views

how to initialize 26 characters inside a 6*5 two dimensional matrix without using and extra special characters

``I am a newbie to Java. All i want to do is to store A to Z inside a 2D array like this A B C D E F G H I J K L M N O P Q R S T U V W X Y Z String alphabets = ...
0
votes
1answer
41 views

Assigning row & column to a 2D array using an array's length

I have data that I am feeding into an array, and I'd like to assign the row & column of a 2D array using simply the length of an array. For instance, if my array has a length of 18, how can I ...
2
votes
4answers
52 views

Nested for loop to print output of 2D array in Java

I have been struggling with the following problem: I am trying to print the below output using nested for loops and two dimensional arrays. int[][] outputArray = { {1,2,3,4,5,6,7,8,9,10}, ...
1
vote
1answer
27 views

How to remove array index from a json_encode php [duplicate]

I'm trying to remove numbers that is being display in my json 2d array. I first had an 2d array that is dynamic and deletes elements from that array. Then it converts the array to a json 2d array. The ...
-1
votes
2answers
40 views

Find and replace strings from 2d array in file

What i want is to search a textfile for a value that the user enters, and replaces it. In my .txt file i have this: 1 2 3 4 5 6 7 8 9 What i want is to load the .txt file (named numbers) and ...
0
votes
1answer
27 views

C# Print 2D array prints split

I'm essentially trying to do the Game Of Life. All seems well, for the most part it works as I want. But for some reason when I go to print it out and have it play, it prints two incomplete parts of ...
0
votes
0answers
13 views

how to convert tree map to 2d array

I am trying to convert a tree map to a 2d array but am not having any luck. I would like to put the key on every i line in the 2d array with it's value on the i+1 line immediately beneath. When I run ...
1
vote
1answer
39 views

2d array multiple movement selection sort

I am trying to write a method that sorts (using bubble sort) the items in every other row of a 2d array. When a movement happens in the first row, I want the category number in the row immediately ...
0
votes
2answers
36 views

C++ Pointer to 2D Dynamic Array?

I am a bit of a C++ newbie and I am working on a project and I a little stuck. I need to create a dynamic 2D ragged array then have a pointer point to it. Here is what I have: int ** x = new int*[3]; ...
0
votes
5answers
52 views

selling a ticket and replacing the sold seat with a 0

This is a movie ticket theatre seller program. The task is create a method that takes the price of the user's input, finds the first seat and replaces it with a 0, denoting a sold seat. I keep ...
0
votes
0answers
41 views

NULL value is coming after modify 2D array values through console/ at run time using Scanner

I am learning Java and have not got good grip on the code at the moment. I have a 2D string array with all the values defined and want to gives the user an option to change the value of any row and ...
0
votes
1answer
32 views

Shuffle polyominos in a grid

I have a 2d array that contains polyominos of lengths 1 to 4, i want to shuffle their position AND rotation. For example: [0,0,1,0,0,0,0,0,0,0] [0,0,1,0,0,0,0,0,0,0] [0,0,1,1,0,0,0,0,0,0] ...
0
votes
0answers
28 views

2-d Array filling logical method

we have a 2-Dimensional array and we need to fill the array in such a way that no value should be repeated in rows and each number should appear exactly twice in each column, please give me the logic ...
1
vote
2answers
34 views

Maze genorator skips spots?

My code(Shown Below) is doing what it's supposed to do (generate a passageway from point a to b with random stops in between) and It works. Well, not all of the time. I have tried to research for ...
-1
votes
1answer
22 views

Return a 2D array from php to android

I'm trying to get data from a database back to my android app to work some magic with it, but I can't seem to find a good way of doing so. The most successful way so far has been to send a long, ...
-2
votes
1answer
35 views

print a column instead of list in python matrix

I have a text file like this: abc 4 2 3 4 1 4 1 2 3 3 abc 4 2 3 4 1 4 1 2 3 3 def 4 3 3 4 1 4 1 2 3 3 def 4 3 3 4 1 4 1 2 3 3 ...
2
votes
4answers
90 views

Create a 2d character array in c

I want to create a 2d character array in C just like this one in php : $matrix = array( array('$','@','*','%','&','#','@','#','#','@'), ...
-2
votes
1answer
44 views

2d Array from JSON with MINIJson

I am a bit noob on JSON and really also c# Anyway I need to load some JSON and setup a gamegrid in unity3d based on a 2d array with the contents from JSON file. I use MINIJson from Darktable which I ...