[ 3 / biz / cgl / ck / diy / fa / ic / jp / lit / sci / vr / vt ] [ index / top / reports ] [ become a patron ] [ status ]
2023-11: Warosu is now out of extended maintenance.

/sci/ - Science & Math


View post   

File: 73 KB, 524x468, 1383244839845774537.jpg [View same] [iqdb] [saucenao] [google]
6349569 No.6349569 [Reply] [Original]

Didn't know where I should start this,

JAVA HELP NEEDED

how the fuck should I program this table?

0 5 5 5 5
4 0 4 4 4
3 3 0 3 3
2 2 2 0 2
1 1 1 1 0

Any help? I can use only tables and loops

>> No.6349576

what is a table

>> No.6349580

>>6349576
table/board

>> No.6349585

If (nCount - 1) mod 6 = 0 // If it minus 1 is a multiple of 6
Output = 0, return;
If (nCount < 6)
Output = 5, return;
If (nCount < 11)
Output = 4, return;
If (nCount < 16)
Output = 3, return;
If (nCount < 21)
Output = 2, return;
else
Output = 1, return;

For nCount from 1 to 25.

>> No.6349589

>>6349569
you just need to print that? any limits on what you're allowed to use (for loops, if statements, etc)?

>> No.6349591

Homework threads are not allowed on /sci/.

>> No.6349597

>>6349580
do you want to visualize a table with swing or what? or do you just want to print a pattern like that in the console?

>> No.6349601

>>6349591
not homework, but something familiar to that.
>>6349597
Yes, whole program is in console, source in notepad saved as .java
>>6349589
no limits, but using only "for" loop is easiest way I believe. Simple print like in 1st post.

>> No.6349607

>>6349569
Store it sequentially in a 1-dimensional array. Then you can get back row and column indeces with i = 1...25, i/5, i%5.

>> No.6349611

Nevermind, I got this:

public static void main (String args[])
{
int tab[][] = new int[5][5];
int a = 5;
for(int j = 0 ; j<5 ;j++){
for(int i = a ; i>0 ;i--){
tab[a-i][j] = a-j;
if((a-i)==j) tab[a-i][j] = 0;
System.out.print(tab[a-i][j]+" ");
}
System.out.println();
}
}
}

>> No.6349616

>>6349601
for i = 1 to 5
for j = 1 to 5
if i = j print 0
else print 6-i
if j = 5 print \n

Too lazy to properly write it in java

>> No.6349618

>>6349569
http://pastebin.com/U0itKnkm

one-million doge please

>> No.6349633

>>6349569
for (int i=5; i >= 1; i--) {
for (int j=1; j <= 5; j++) {
if (j != 5 - i + 1) {
System.out.print(i);
} else {
System.out.print(0);
}
System.out.println();
}
}

>> No.6352009

>>6349569
public staic void main(){
System.out.println("0 5 5 5 5");
System.out.println("4 0 4 4 4");
System.out.println("3 3 0 3 3");
System.out.println("2 2 2 0 2");
System.out.println("1 1 1 1 0");
System.out.println("Fuckin freshmen, you're not gonna make it..");
}

>hth

>> No.6352069

>>6352009
>Any help? I can use only tables and loops