Advertisement
Guest User

Untitled

a guest
Jan 27th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.52 KB | None | 0 0
  1. package a;
  2. import java.util.*;
  3. public class J4 {
  4.     private static double[] A = new double[101];
  5.     private static String toString(double[] A) {
  6.         String s = "";
  7.         for(double i : A) {
  8.             if(i > 0.4) {
  9.                 s = s + Math.round(i) + " ";
  10.             }
  11.         } return s;
  12.     }
  13.     private static void split(int x1, double x2) {
  14.         double c1 = A[x1 - 1] * x2 / 100.0;
  15.         double c2 = A[x1 - 1] - c1;
  16.         for(int i = A.length - 2; i >= x1; i--)
  17.             A[i+1] = A[i];
  18.         A[x1] = c2;
  19.         A[x1 - 1] = c1;
  20.     }
  21.     private static void join(int x) {
  22.         double c = A[x] + A[x-1];
  23.         for(int i = x; i < A.length - 1; i++)
  24.             A[i] = A[i+1];
  25.         A[x - 1] = c;
  26.     }
  27.     public static void main(String[] args) {
  28.         Scanner s = new Scanner(System.in);
  29.         int a = s.nextInt();
  30.         CountTime.ms(1); //Timer Start
  31.         for(int i = 0; i < a; i++) {
  32.             A[i] = (double) s.nextInt();
  33.         }
  34.         while(true) {
  35.             int j = s.nextInt();
  36.             if(j == 99) {
  37.                 int x1 = s.nextInt();
  38.                 double x2 = (double)s.nextInt();
  39.                 split(x1, x2);
  40.             }
  41.             if(j == 88) {
  42.                 int x1 = s.nextInt();
  43.                 join(x1);
  44.             }
  45.             if(j == 77) {
  46.                 System.out.println(toString(A));
  47.                 break;
  48.             }
  49.         }
  50.         System.out.printf("Runtime: %dms",CountTime.count); //Timer Stop
  51.     }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement