Skip to content

Commit 79ad325

Browse files
authored
Create Salyangoz.java
1 parent 76c7695 commit 79ad325

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

Salyangoz.java

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package com.company;
2+
3+
import java.util.Scanner;
4+
5+
public class Salyangoz {
6+
public static void main(String args[]){
7+
Scanner scanner = new Scanner(System.in);
8+
System.out.print("Sayı Giriniz: ");
9+
int sayi = scanner.nextInt();
10+
int neredeyiz = 1;
11+
int[][] tablo = new int[sayi][sayi];
12+
for(int satir = 0; satir < sayi; satir++){
13+
if(satir%2 == 0){
14+
for(int sutun = 0; sutun<sayi; sutun++){
15+
tablo[satir][sutun] = neredeyiz;
16+
neredeyiz++;
17+
}
18+
}else{
19+
for(int sutun = sayi-1; sutun >= 0; sutun--){
20+
tablo[satir][sutun] = neredeyiz;
21+
neredeyiz++;
22+
}
23+
}
24+
}
25+
26+
for(int satir = 0; satir<sayi; satir++){
27+
for(int sutun = 0; sutun<sayi; sutun++){
28+
System.out.print(tablo[satir][sutun]+" ");
29+
}
30+
System.out.println("");
31+
}
32+
}
33+
}

0 commit comments

Comments
 (0)