forked from bugresearch/java-basic-projects
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKosegenibir.java
More file actions
26 lines (23 loc) · 729 Bytes
/
Kosegenibir.java
File metadata and controls
26 lines (23 loc) · 729 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package com.company;
import java.util.Scanner;
public class Kosegenibir {
public static void main(String args[]){
Scanner scanner = new Scanner(System.in);
System.out.print("Sayı Giriniz: ");
int sayi = scanner.nextInt();
if(sayi >= 2){
int[][] dizi = new int[sayi][sayi];
for(int i = 0; i<sayi; i++){
dizi[i][i] = 1;
}
for(int a = 0; a < sayi; a++){
for(int b = 0; b < sayi; b++){
System.out.print(dizi[a][b]+" ");
}
System.out.println("");
}
}else{
System.out.println("Sayı 1'den büyük olmalıdır.");
}
}
}