Skip to content

Instantly share code, notes, and snippets.

@SageStarCodes
Last active January 19, 2016 16:05
Show Gist options
  • Save SageStarCodes/b7b57590c583fa3add34 to your computer and use it in GitHub Desktop.
Save SageStarCodes/b7b57590c583fa3add34 to your computer and use it in GitHub Desktop.
Pridal som private na premenné a package
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