s.kartheepan
BAN USER- 0of 0 votes
Answersgive bi matrix 5 dimensional array
- s.kartheepan in United States for VDirector
{1 ,2, 3, 4,6},
{5, 4, 3, 5,7},
{6, 5, 9, 8,9},
{9, 8, 7, 6,1},
{1, 8, 3, 6,2}
the output that needs to print is
1
25
346
4359
65981
7878
963
16
2
write an algorithm in java
clue size of the bi dimensional array
and factorial of the size
and verify the indexes of the numbers in the output
for each number
they form a pattern
write in a paper all the indexes
ull understand the pattern| Report Duplicate | Flag | PURGE
EMC Consultant Algorithm
before I posted the question I figured out the solution already.Wanted to see the response.
package com.sf.algorithmsStrcutures.binarySearch;
public class printBiMatrix {
static int a[][] = { {1 ,2, 3, 4},
{5, 4, 3, 5},
{6, 5, 9, 8},
{9, 8, 7, 6}
};
static int factorial(int n){
int factorial = 1 ;
int max = n;
for(int index = max;index>0;index-- ){
factorial = factorial * index;
}
return factorial;
}
/**
* @param args
*/
public static void main(String[] args) {
int size = a.length;
//int numberOfChances = factorial(size);
for(int index=0;index < 2*size;index++){
for(int i=0;i < size;i++){
for(int j=0;j< size;j++){
if((i + j) == index){
System.out.print(a[i][j]);
}
}
}
System.out.println();
}
}
}
//Increase the bimatrix array into any size like 5*5 or 6*6 or 7*7 or 8*8
But I guess your program does not meet the demanded output.So please refactor them more to print the demanded output.
- s.kartheepan February 09, 2013
Repallisonepollard, Applications Developer at Accenture
I am Allison from Germantown. I work as a Staff manager at The LawnGuru company. But my interest in blogging ...
I guess something is missing in your code.Your code prints
- s.kartheepan February 10, 20131
25
346
4359
65981
7878
878
78
8
The expected output is
1
25
346
4359
65981
7878
963
16
2