Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Random;
- public class For_za_Metodu {
- public static void main (String[] args) {
- double [] field = new double [11];
- Random lubsa = new Random();
- int i;
- for (i=1; i<=10; i++) { // vygenerovani pole a zaokrouhleni clenu
- field[i]=lubsa.nextDouble()*10;
- field[i]=Math.round(field[i]*100);
- field [i]= field[i]/100;
- }
- tisk (field); // tisk pole pomocí medoty
- System.out.println();
- for (i=1; i<=10; i++) { // upravy clenu pole
- if (i % 2 == 1) {
- field [i]=2*field [i];
- }
- }
- tisk (field); // tisk zmeneneho pole
- }
- final static void tisk (double [] pole) { // metoda pro tisk
- for (int i=1; i<=10; i++){
- System.out.print(pole [i] + " ");
- }
- }
- }
Add Comment
Please, Sign In to add comment