public class naloga_3 {
public static void main
(String[] args
) { int[] stevilo = new int[1000];
int vsota_p = 0, poz = 0, vsota_n = 0, neg = 0, max = 0, prva_poj = 0, zadnja_poj = 0;
boolean _prva_poj = false;
for(int i = 0; i < stevilo.length; i++) {
stevilo
[i
] =
(int)Math.
round(Math.
random() *
2000 -
1000);
if(stevilo[i] < 0) {
vsota_n += stevilo[i];
neg++;
}
if(stevilo[i] > 0) {
vsota_p += stevilo[i];
poz++;
}
if(i == 0 || stevilo[i] > max) {
max = stevilo[i];
}
}
vsota_n /= neg;
vsota_p /= poz;
int vsota = vsota_n + vsota_p;
System.
out.
println("Povprecje negativnih stevil je: " + vsota_n
);
System.
out.
println("Povprecje pozitivnih stevil je: " + vsota_p
);
System.
out.
println("Stevila vecja od povprecja vseh stevil, ki je " + vsota +
":");
for(int i = 0; i < stevilo.length; i++) {
if(stevilo[i] > vsota) {
System.
out.
println(stevilo
[i
]);
}
if(stevilo[i] == max) {
if(_prva_poj != true) {
prva_poj = i;
_prva_poj = true;
}
zadnja_poj = i;
}
}
System.
out.
println("Mesto prve pojavitve max stevila je na indexu: " + prva_poj
);
System.
out.
println("mesto zadnje pojavitve max stevila je na indexu: " + zadnja_poj
);
}
}