Tagged Questions
-1
votes
0answers
16 views
Shortest Path 2d array javascript
Hello so i am trying to come up with a 2d shortest path algorithm using Dijkstra's shortest path algorithm. I understand the concept of the algorithm we are using a breadth first search. I believe my ...
1
vote
2answers
28 views
Filling in the main diagonals in a 2D array
I am trying to write a code that fills in the 2 main diagonals in an NxN matrix, for example:
if N=5 (which is entered through command line), we would have a 5x5 matrix filled with zeros and the ...
0
votes
3answers
26 views
(*twod)[3] vs *(twod)[3] C Pointers
I'm learning C and have a question of: Explain the difference between int (*twod)[3] as a parameter as compared to int *(twod[3]). I don't really know what the difference is completely. If someone ...
-1
votes
0answers
15 views
How do I store a 1D char array into a specific position in a 2D array in java?
I'm trying to take a 1D character array and store it in each position in a 2D array. Here's what I've got, trying to store the array {'a','b','c'} into each position of my 2D array.
char[][] ...
0
votes
3answers
23 views
Getting inputs from the text file and storing as 2-d pattern in python
Suppose I have the text file contents as:
00 0.21
11 0.12
10 2.51
01 0.25
Where the first column is binary and the second column is float value. After reading to the text file my output ...
0
votes
2answers
23 views
Why does this code for shifting left in a 2D array not work and shifts left 2 instead?
This code is to shift a 2D array "arr" to the left completely once it runs through, but for some reason, the elements are shifting over by two.
public static void shiftLeft()
{
...
-6
votes
0answers
54 views
filling and printing a 2d array from 100 to 1 [duplicate]
I'm new to java and was wondering how I can go about filling and printing a 2d array [10][10] from 100 down to 1, like a snakes and ladders board.
Thanks for any help!
0
votes
3answers
32 views
Initializing a global 2D array in C from a function
float verticies[14][3];
init_mod(){
verticies = {{-0.5,-0.5, 0.5},
{ 0.5,-0.5, 0.5},
{-0.5, 0.5, 0.5},
{ 0.5, 0.5, 0.5},
{-0.5, 0.5,-0.5},
{ 0.5, 0.5,-0.5},
{-0.5,-0.5,-0.5},
...
0
votes
4answers
48 views
C: Pass 2D int array
I'm having issues passing a 2d integer array to a function array in C. My task is to scan lines of integers from stdin into a 2d array, and then pass that array off to another function for processing. ...
-1
votes
1answer
29 views
2d array matrix not printing properly
Matrix is not printing properly, Can anyone tell me where I went wrong??
int i , j;
int n =0 , m =0;
int p =0 , q =0;
int matrix1[n][m];
int matrix2[p][q];
...
0
votes
0answers
44 views
Arrays containing indexes to retrieve values from another array
I have this problem and I don't know if it is possible to implement.. but here it goes.
Basically, I have to get the position of the conjunctive query variables and apply those indexes to retrieve ...
1
vote
4answers
40 views
Seg Fault with 2D array
I'm not sure why my 2d array initialization causes a seg fault, so I have
void viterbi_algorithm(double init[], double A[][26], double B[][2], int obs[],
int ...
0
votes
1answer
12 views
Import Data into 2d Array from .txt
I am having trouble creating a method to import data from a txt file into a 1d string array and a 2d double array.
Here is what I have thus far:
public static void main(String[] args){
String[] ...
0
votes
3answers
40 views
Save part of an 2D array into another 2D array Java
I have a 2D array which holds an ASCII map. I have another function called botLook() which needs to store a section of the map into another 2D array. This is a section of the map which the bot can ...
0
votes
1answer
31 views
How to use 2d array with form in Ruby on Rails?
I have a model. In that model, I created an array attribute, but I can't use that attribute in form.
This is my problem:
= form_for :my_form_name do |f|
%table
- for i in 1..10 do
%tr
...
0
votes
1answer
40 views
Checking adjacent indices in 2 dimensional array
I have to write minesweeper.
I've figured out a way to check the adjacent indices to count how many bombs surround the current index without going out of bounds. But it's long, ugly, and most likely ...
0
votes
4answers
40 views
Passing and returning 2d arrays in C++
So I am new to c++ and I have written this piece of c++ code.
#include <iostream>
using namespace std;
int** mat_mult(int mat1[2][2], int mat2[2][2]){
int mat3[2][2] = {{0,0},{0,0}};
...
1
vote
4answers
58 views
Check duplicate in rows and columns 2D Array
how would I go about checking a duplicate for columns and rows and return true or false depending if there's duplicates. For example
1 2 3
3 1 2
2 3 1
Would return true because no duplicates, ...
0
votes
2answers
52 views
Reverse the rows of a 2d array
Yesterday I asked a very similar question and I kind of messed up with asking it.
I need to pass an array to a method and inside of that method I need to swap the rows around so if it's
1 2 3
3 2 ...
0
votes
2answers
30 views
How to display numbers on the left side and on the bottom of my 2D array?
I need to print a 2 dimensions array with some numbers on the left side and on the bottom.
Here is my code for the initialization, wich is in the class Grille :
class Grille {
String[][] grille = ...
3
votes
2answers
42 views
how do you add to a 2D arraylist
I have the following code. I know the star is correct but I can't add to the arraylist
private ArrayList<int[]> action = new ArrayList<int[]>();
action.add(new int[2]);
then I have
...
1
vote
2answers
59 views
Is the statement *a[i]++ /= K valid?
Array initialization Code:
int m = 100;
int n = 50;
int i = 0, j = 0;
float **a = (float**)malloc(m*sizeof(float*));
for (i = 0; i < m; i++)
{
a[i] = (float*)malloc(n*sizeof(float));
for ...
-1
votes
1answer
39 views
2D Array in Java with number manipulation
My goal is to
Create a 5x5 array and fill it with random integers in the range of 1 to 25.
Print this original array
Process the array, counting the number of odds, evens, and summing all of the ...
0
votes
1answer
25 views
Array for 2 listviews in 1 Android Activity
I’m new to android development… I want to pass data to 2 ListViews through an ARRAY . Should I use a 2D array.? Then how?
What I want to do is;
Eg:In ListView1 there are
Fruits
Vegetables
Meat
...
0
votes
2answers
45 views
how to read array of numbers from text file in python
I have written code as:
array = [[1.630217208498539], [0.019929319226538452]]
fo = open("file.txt", "w")
fo.write(str(array))
fo.close()
That will save the array in .txt file, the content in the ...
0
votes
2answers
34 views
Create and sort 2d array from file
Okay so basically I have to accomplish 2 things with this code. 1. Sort the two columns from the file into an array and 2. arrange them in order from largest to smallest based on the second column.
...
-2
votes
2answers
55 views
C++ Sudoku Solver
Need help figuring out what is wrong with the readPuzzle and printPuzzle functions. SetOfSmallInts is a set containing {1,2,3,4,5,6,7,8,9} or any combination of those numbers. singletonSet(s) store a ...
2
votes
2answers
64 views
how to create a vector of int 2D array in c++ [duplicate]
i am trying to create a vector of int 2D array in c++
but my following code has some errors that i can't realize why?!
vector< int[2][2] > vec;
int a[2][2];
vec.push_back(a);
i don't want to ...
-4
votes
1answer
51 views
Reading in a 2d array C++ [closed]
I have to make a program that solves sudoku puzzles. The types of each cell are SetOfSmallInts a set containing {1,2,3,4,5,6,7,8,9} or any combination of the numbers. I can not figure out how to read ...
-3
votes
3answers
49 views
ArrayIndexOutOfBoundsException, only prints first line
I am making a dungeon game in Java. I have created a method that stores a map in a 2D array. The array looks like this:
[[#, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #],
[#, ., ., ., ., ., ...
1
vote
1answer
37 views
Adding columns in a 2D array
I'm trying to sum up each column I have to my 7th row but I can't figure out how to display something like:
100 101 102 103 104 105
106 107 108 109 110 111
112 113 ...
0
votes
2answers
62 views
issue with for loops in 2D array program
Okay so my current assignment has me making a program that can mimic percolation, meaning that it has to read an array, where 1 means the space is closed, 0 means the space is open. Next, it must ...
0
votes
2answers
65 views
Import ascii world map in Java
I need to import a as ascii map into my Java game to set the world you will be able to move around in.
For example.
###################
#.................#
#......G........E.#
#.................#
...
0
votes
1answer
33 views
load txt file (m x n matrix) into 2d double array
I would like to load data from my txt file and store them in a 2D double array.
I was trying something like this:
String input = File.ReadAllText(@"E:\c\vstup.txt");
int k = 0, l = 0;
double[][] ...
0
votes
4answers
93 views
Index out of bounds when using a two-dimensional array
I am creating a text based minesweeper game in Java. The game works fine if a user creates a perfect square for a game board, however if they enter two different values, I get an exception at the ...
0
votes
1answer
42 views
using malloc() with 2d array, not getting expected results
Program takes a malloc'd char * from another function into a malloc'd heigth x width grid. I can't help but think it's the way I'm filling the grid that's faulty. For debugging I've added the print of ...
0
votes
2answers
26 views
Creating and initialising a 2D Array in Java
I haven't used 2D Arrays before so apologies for any 'obvious statements'.
I want to create a 2D Array for a 15 by 20 'table' and want the following to be applied:
I want each row to be a separate ...
0
votes
4answers
26 views
Out of bounds searching 2 dimensional array
I'm trying to search through an array of arrays (17 rows and 26 columns) for one integer and print the index of that integer. For the sake of easy testing I've set the integer I'm searching for to 0, ...
0
votes
2answers
24 views
How to input a string one charecter at a time into a 2d array
So i have a string and i need to put it into a 2d array this is what i have so far.
mazeString = ".............."
char[][] mazeArray = new char [50][30];
for (int i = 0; i < ...
0
votes
1answer
28 views
Place String into 2 dimensional array
To put a String into a single array is easy but I want to put a string into a 2d char[][];
I'm stuck here, can some one help me please ... Thank u, ans sorry for my bad English!
String woord = ...
0
votes
3answers
55 views
Java cannot create simple 2d boolean array
Running the code:
public static boolean[][] makeright(boolean tf, BufferedImage in){
boolean[][] ret = new boolean[in.getWidth()][in.getHeight()];
Arrays.fill(ret, tf);
...
0
votes
4answers
66 views
How to Get the Rows and Columns from 2d array c++
I've created an 2D array in C++ like this:
Board::Board(int rows, int cols){
places = new int*[rows];
for (int row = 0; row < rows; row++){
places[row] = new int[cols];
for ...
0
votes
1answer
38 views
Find and return all cycles given a 2D array
I have an int[,] 2D array representing a house in a coordinate system. Each index is a type of enum representing building blocks, such as none=0, wall=1, stairs =2. The only part that I'm interested ...
0
votes
1answer
83 views
c++ 2d array maze navigation
I'm new to c++ and wondering if I'm doing this the best way. I need to read in a line from a text file and build an array from it and then navigate it. Let me know if I'm doing something wrong. Can I ...
0
votes
2answers
31 views
“Garbage” values in 2D array when trying to print via function
I'm making a classic tic-tac-toe type game but with the board size defined by the user.
When trying to print the board (with asterisks representing open spaces) after the user specifies a size for ...
0
votes
1answer
84 views
Stuck in using 2D arrays?
I am not good with arrays.In the below code there are 2 methods which takes the data from two 2D Arrays.The first method COMBINATION is working correctly.But the second Method doesn't.
Am I doing ...
1
vote
1answer
89 views
How to match edges of contiguous 2D arrays and Smooth them (Heightmaps)
This problem is driving me crazy, I have searched and thicked but can't achieve a solution.
I have some 2D arrays of floats [,] (by the way I'm using C#), and put together always form a square. There ...
1
vote
4answers
31 views
How to fix 2D Array that prints as one column
so this is what my code actually looks like, i was trying to make a simple 2d 10 by 10 array with just zeros at first. The zeros print in one column with breaks where a new column should be starting
...
-1
votes
2answers
92 views
Beginner 2D-Array out of bounds exception
I'm having some difficulties trying to figure out how to implement a second array to calculate the averages of my marks program.
I'm using 1 2D array to store the scores each student received on each ...
0
votes
0answers
31 views
projections and index on 2D nested arrays in mongodb
> db.foo.save({'foo': [{f0: 'a', f1: 'b'}, {f0: 'c', f1: 'd'}]})
> db.foo.save({'foo': [{f0: 'a', f1: 'e'}, {f0: 'f', f1: 'g'}]})
> db.foo.save({'foo': [['a', 'b'], ['c', 'd']]})
> ...