Skip to content

Commit fd7b459

Browse files
author
ssavi08
committed
Initial commit
0 parents  commit fd7b459

32 files changed

+887
-0
lines changed

.gitignore

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
### IntelliJ IDEA ###
2+
out/
3+
!**/src/main/**/out/
4+
!**/src/test/**/out/
5+
6+
### Eclipse ###
7+
.apt_generated
8+
.classpath
9+
.factorypath
10+
.project
11+
.settings
12+
.springBeans
13+
.sts4-cache
14+
bin/
15+
!**/src/main/**/bin/
16+
!**/src/test/**/bin/
17+
18+
### NetBeans ###
19+
/nbproject/private/
20+
/nbbuild/
21+
/dist/
22+
/nbdist/
23+
/.nb-gradle/
24+
25+
### VS Code ###
26+
.vscode/
27+
28+
### Mac OS ###
29+
.DS_Store

.idea/.gitignore

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/uiDesigner.xml

+124
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

FERIT.iml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module type="JAVA_MODULE" version="4">
3+
<component name="NewModuleRootManager" inherit-compiler-output="true">
4+
<exclude-output />
5+
<content url="file://$MODULE_DIR$">
6+
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
7+
</content>
8+
<orderEntry type="inheritedJdk" />
9+
<orderEntry type="sourceFolder" forTests="false" />
10+
</component>
11+
</module>

LV2.rar

622 Bytes
Binary file not shown.

src/dodatniZad/zad1/Main.java

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package dodatniZad.zad1;
2+
3+
import java.util.Scanner;
4+
5+
public class Main {
6+
public static void main(String[] args) {
7+
Scanner input = new Scanner(System.in);
8+
int n = input.nextInt();
9+
10+
int[][] a = new int[n][n];
11+
12+
for(int i=0; i<n; i++){
13+
for(int j=0; j<n; j++){
14+
a[i][j] = input.nextInt();
15+
}
16+
}
17+
18+
int[] sRed = new int[n];
19+
int[] sStup = new int[n];
20+
int sGd=0, sSd=0;
21+
22+
for(int i=0; i<n; i++){
23+
for(int j=0; j<n; j++){
24+
sRed[j] += a[j][i];
25+
sStup[i] += a[i][j];
26+
if(i == j){
27+
sGd += a[i][j];
28+
}
29+
if((i+j)==n-1){
30+
sSd += a[i][j];
31+
}
32+
}
33+
}
34+
int fd=0;
35+
36+
for(int i=0; i<n; i++){
37+
for(int j=0; j<n; j++){
38+
System.out.print(a[i][j]);
39+
}
40+
System.out.println("");
41+
}
42+
for(int j=0; j<n; j++){
43+
if(sRed[j] == sStup[j] && sStup[j] == sGd && sGd == sSd){
44+
fd=1;
45+
}else{
46+
fd=-1;
47+
}
48+
}
49+
50+
System.out.println(fd);
51+
}
52+
}

src/predrok1/zad1/Main.java

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package predrok1.zad1;
2+
3+
import java.util.Scanner;
4+
5+
/*potrebno je napisati program koji ce za kvadratnu matricu A s N redaka i N stupaca koja u sebi ima samo nule i
6+
jedinice, izracunati koliko ima ponavljanja broja 0, a da su oko njega sve jedinice*/
7+
public class Main {
8+
public static void main(String[] args) {
9+
10+
Scanner input = new Scanner(System.in);
11+
12+
int n = input.nextInt();
13+
int[][] A = new int[n][n];
14+
15+
//Unosenje 0 i 1
16+
for(int i=0; i<n; i++){
17+
for(int j=0; j<n; j++){
18+
int unos;
19+
do{
20+
A[i][j] = input.nextInt();
21+
unos = A[i][j];
22+
}while( unos != 0 && unos != 1 );
23+
}
24+
}
25+
26+
System.out.println(String.valueOf(funkcija(A, n)));
27+
}
28+
29+
public static int funkcija(int[][] a, int b){
30+
int brojac = 0;
31+
32+
for(int i=1; i<b-1; i++){
33+
for(int j=1; j<b-1; j++){
34+
if( a[i][j] == 0 && a[i-1][j-1]==1 && a[i][j-1]==1 && a[i+1][j-1]==1 && a[i-1][j]==1 && a[i+1][j]==1 && a[i-1][j+1]==1 && a[i][j+1]==1 && a[i+1][j+1]==1){
35+
brojac++;
36+
}
37+
}
38+
}
39+
return brojac;
40+
}
41+
}

src/predrok1/zad2/Main.java

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package predrok1.zad2;
2+
3+
import java.util.Scanner;
4+
5+
public class Main {
6+
public static void main(String[] args) {
7+
Scanner input = new Scanner(System.in);
8+
int n = input.nextInt();
9+
int[][] A = new int[n][n];
10+
11+
for(int i=0; i<n; i++){
12+
for(int j=0; j<n; j++){
13+
A[i][j] = input.nextInt();
14+
}
15+
}
16+
17+
for(int i=0; i<n; i++){
18+
Nit nit = new Nit(A, i);
19+
nit.start();
20+
}
21+
22+
input.close();
23+
}
24+
}

src/predrok1/zad2/Nit.java

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package predrok1.zad2;
2+
3+
public class Nit extends Thread{
4+
private final int[][] A;
5+
private final int redak;
6+
7+
public Nit(int[][] A, int redak){
8+
this.A = A;
9+
this.redak = redak;
10+
}
11+
12+
@Override
13+
public void run(){
14+
int suma = 0;
15+
16+
for(int stupac : A[redak]){
17+
suma = suma + stupac;
18+
}
19+
System.out.println("Nit "+redak+" suma="+suma);
20+
}
21+
}

0 commit comments

Comments
 (0)