-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathEnBuyukBulma.java
More file actions
36 lines (31 loc) · 1.06 KB
/
EnBuyukBulma.java
File metadata and controls
36 lines (31 loc) · 1.06 KB
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
27
28
29
30
31
32
33
34
35
36
package com.company;
import java.util.Scanner;
public class EnBuyukBulma {
public static void main(String args[]){
Scanner scanner = new Scanner(System.in);
System.out.print("Kaç Tane Sayıyı Karşılaştıracaksınız: ");
int kactane = scanner.nextInt();
if(kactane > 0){
int[] dizi = new int[kactane];
for(int i = 0; i < dizi.length; i++){
System.out.print("Sayı Girin: ");
int sayi = scanner.nextInt();
dizi[i] = sayi;
}
int enbuyuk = dizi[1];
int enkucuk = dizi[1];
for(int i = 0; i < dizi.length; i++){
if(i > enbuyuk){
enbuyuk = i;
}
if(i < enkucuk){
enkucuk = i;
}
}
System.out.println("En Büyük Sayı: "+enbuyuk);
System.out.println("En Küçük Sayı: "+enkucuk);
}else{
System.out.println("0'dan büyük bir değer giriniz.");
}
}
}