Last active
January 19, 2016 16:05
-
-
Save SageStarCodes/b7b57590c583fa3add34 to your computer and use it in GitHub Desktop.
Pridal som private na premenné a package
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ulohy; | |
import java.util.Scanner; | |
public class Uloha2 { | |
private static float[][] pole = new float[5][5]; | |
private static float[][] pole2 = new float[5][5]; | |
private static Scanner sc = new Scanner(System.in); //nevsimat si, iba pre Javu, konvertuje byte InputStream na Scanner, ktorý môže byť čokolvek | |
public static void main(String[] args){ | |
System.out.println("Zadaj 25 cisel:"); | |
for(int i=0;i<5;i++) { | |
for(int j=0;j<5;j++){ | |
pole[i][j] = (float) sc.nextInt(); | |
if(i%2 == 0 && j%2 == 0) { | |
pole2[i][j] = pole[i][j] * -1.0f; | |
} | |
else if(i%2 == 0 && j%2 != 0) { | |
pole2[i][j] = pole[i][j] + (pole[i][j]/2); //pre istotu do zátvorky | |
} | |
else if(i%2 != 0 && j%2 == 0) { | |
pole2[i][j] = pole[i][j] + 2.0f; | |
} | |
else { //i aj j sú nepárne | |
pole2[i][j] = pole[i][j] - 6.0f; | |
} | |
} | |
} | |
//vypisat polia | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment