Good day guys, I would just like to share my code and wanted to do something about it. This code shows a loop inside a loop initializing a two-dimensional array named arr with elements [2] and [5]. Here's my code: #include <iostream> #include <conio.h> using namespace std; int main () int arr [2] [5]; int val = 1; for (int i = 0; i < 2; i++) { for (int j = 0; j < 5; j++) { arr [i][j] = val; cout << arr [i][j] << " "; val++; } cout << endl; } getch (); return 0; }{ …

Member Avatar
Member Avatar
+0 forum 3

I cant figure out how to check the array for AND and OR. please, help, i got stuck my code: import java.util.Scanner; public class BooleanProduct import java.util.Scanner; public class BooleanProduct { public static void main(String[] args) { Scanner input = new Scanner(System.in); int[][] A = new int[10][10]; int[][] B = new int[10][10]; int[][] C = new int[10][10]; int m,n,p,q; System.out.println("Enter number of rows for matrix A : "); m = input.nextInt(); System.out.println("Enter number of columns for matrix A : "); n = input.nextInt(); System.out.println("Enter number of rows for matrix B : "); p = input.nextInt(); System.out.println("Enter number of columns for …

Member Avatar
Member Avatar
+0 forum 3

import java.util.Scanner; public class BooleanProduct { public static void main(String[] args) { Scanner input = new Scanner(System.in); int n = 10; int[][] A = new int[n][n]; int[][] B = new int[n][n]; //Fill A and B int m,n2,p,q; System.out.println("Enter number of rows for matrix A : "); m = input.nextInt(); System.out.println("Enter number of columns for matrix A : "); n2 = input.nextInt(); System.out.println("Enter number of rows for matrix B : "); p = input.nextInt(); System.out.println("Enter number of columns for matrix B : "); q = input.nextInt(); System.out.println("Enter elements for matrix A (by rows): "); for (int i=0 ; i < m …

Member Avatar
Member Avatar
+0 forum 4

Hi guys, im currently doing Conway's game of life and i'm almost there. The variable and all is in German since im studying here in Germany but i think one can still understand the code. There's one thing I need help with, which is with the Glider (Gleiter). When i run it, the output is that the Glider wil move diagonally from **bottom left to upper right**. As it reaches the end of the field, i am required to make that it will appear again from **bottom right moving to upper left**. (Moves in a way that form an 'X') …

Member Avatar
Member Avatar
+0 forum 3

Hello perhaps you could help me with a problem please. I wish to display a table of results using a JTable. Customarily I use a 2D Object array which is initialized with the data in a manner as follows: public Object[][] data={ {"Biology",25},{"Additional Math", 54},{"Geography",43},{"History",21},{"Spanish", 47}, {"Information Tech.",110},{"Technical Drawing",54},{"French",45},{"Physics",76},{"Chemistry",76}, {"Principles of Accounts",34},{"Principles of Business",30} }; However this time, initialising won't work because the data that I am receiving will be subject to change, thus the 2D array needs to be created at a later point. The added data that I will be receiving, will come from two(2) arrays, one containing …

Member Avatar
Member Avatar
+0 forum 2

I've got this thing that has kept me puzzling for a few days now. I've created an array of 30 integers, randomly chosen. I would like to add the integers randomly to a two-dimensional array of 12 x 12 integers. The remaining elements in the two-dimensional array should keep their null value. I have no clue about how to get these integers **randomly** into the two-dimensional array, though. Any wizzards here who would like to help me out ?

Member Avatar
Member Avatar
+0 forum 1

Write a java program that will open a file, read each of the records from the file, use that data to populate a two dimensional array and write the sorted data out to a new text file. Define a class named [B]Munge[/B] which will do all the 'heavy lifting' in this program. Build your project in NetBeans using the Run - Build Project, or Run - Clean and Build Project menu item. From the dist directory you will execute your program from the command line with two filenames as arguments, input file name and output file name. For example: [B]java …

Member Avatar
Member Avatar
+0 forum 4

Hello All I'm not quite sure you can do this but it seems to me like something python is probably able to do. Basically, I need to assert that somewhere in my list of lists i have a '2', and a '1'. Now my lists in the biglist are all the same length. By which i mean that len(BigList[i]) == len(BigList[i+1] for all valid indicies i. I was just thinking something like this: [CODE][element for element in SmallList for SmallList in BigList][/CODE] I understand why this doesn't work, but for some reason, i'm pretty sure that it can be done …

Member Avatar
Member Avatar
+0 forum 4

I have a two-d array from which I need to read values from any and all sides of each index. for example [CODE]int x=0, y=0; myArray [x - 1][y - 1];[/CODE] where x-1 and y-1 would be the values of the other end of the array. I've been up over 24 hours trying to write this program, and my mind's far from lucid. Can someone PLEASE tell me how to do this being as elaborate as possible (or even better providing the complete code). THANK YOU IMMENSELY!

Member Avatar
Member Avatar
+0 forum 3

I need to write a program for class that calculates student averages and quiz averagages. It has to read a 2-dim array from a file that looks like this: 10 10 10 2 0 1 8 6 9 8 4 10 The four students are the rows and the three quizzes are the columns. Then I have to change the 2-dim inout into 1-dim arrays to get this output. My output needs to look like this: Student Averages Quizzes 1 10.0 10 10 10 2 1.0 2 0 1 3 7.7 8 6 9 4 7.3 8 4 10 Quiz …

Member Avatar
Member Avatar
+0 forum 2

Greetings to the community! I am trying to print a two-dimensional character array and it is printing out ASCII values instead of the actual characters. I think the solution is simple but I can't figure it out. The following is the code snippet and the function that I am using to print out the character array: [CODE] char e = 'F'; char[][] a = new char[5][5]; a[2][3] = e; prA(a); private void prA(char[][] a){ for(int i=0; i<a.length; i++){ for(int j=0; j<a[i].length; j++){ System.out.print(a[i][j] + ' '); } System.out.println(); } } [/CODE] The following is the output that I am getting: …

Member Avatar
Member Avatar
+0 forum 5

I've been writing a piece of code that will use a brute force approach to find 50 exponential equations that fit 5 points (x,y) that i've entered. The code is fine and works without a glitch.. The problem is when i try to make it keep a record of the 50 best equations. This sort routine is the one i've been using.. I've put it in its own test class just to make easier to follow. The current problem is it ends up displaying something completely unwarranted and the array ends up with only two different values. [CODE]public class sortTest{ …

Member Avatar
+0 forum 0

The End.