Advertisement
EugenyB

Пример кода от 28.02 для группы К9

Feb 28th, 2012
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.02 KB | None | 0 0
  1. package arrays;
  2.  
  3. import java.util.Arrays;
  4.  
  5. /**
  6.  *
  7.  * @author Eugeny
  8.  */
  9. public class Main {
  10.  
  11.     private double[] x = new double[5];
  12.     private double[] y = {2.4, 5.9, 1.3, -5};
  13.     private double[] z = new double[]{2.5, 3.1, -2.4};
  14.  
  15.     public double getX(int i) {
  16.         return x[i];
  17.     }
  18.    
  19.     public void setX(double[] x) {
  20.         this.x = x;
  21.     }
  22.    
  23.     public void run() {
  24.         // можно сделать и так
  25. //        y = new double[]{3.5, 4};
  26.         for (int i = 0; i < y.length; i++) {
  27. //            System.out.println("z=" + z[i]);
  28.             System.out.println("y=" + y[i]);
  29. //            System.out.println("z=" + z[i]);
  30.         }
  31.         Arrays.sort(y);
  32.         for (double d : y) {
  33.             System.out.println("y="+d);
  34.         }
  35.         double s = 0;
  36.         for (double d : y) {
  37.             s+=d;
  38.         }
  39.     }
  40.  
  41.     /**
  42.      * @param args the command line arguments
  43.      */
  44.     public static void main(String[] args) {
  45.         new Main().run();
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement