Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class J4 {
- private static double[] A = new double[101];
- private static String toString(double[] A) {
- String s = "";
- for(double i : A) {
- if(i > 0.4) {
- s = s + Math.round(i) + " ";
- }
- } return s;
- }
- private static void split(int x1, double x2) {
- double c1 = A[x1 - 1] * x2 / 100.0;
- double c2 = A[x1 - 1] - c1;
- for(int i = A.length - 2; i >= x1; i--)
- A[i+1] = A[i];
- A[x1] = c2;
- A[x1 - 1] = c1;
- }
- private static void join(int x) {
- double c = A[x] + A[x-1];
- for(int i = x; i < A.length - 1; i++)
- A[i] = A[i+1];
- A[x - 1] = c;
- }
- public static void main(String[] args) {
- Scanner s = new Scanner(System.in);
- int a = s.nextInt();
- for(int i = 0; i < a; i++) {
- A[i] = (double) s.nextInt();
- }
- while(true) {
- int j = s.nextInt();
- if(j == 99) {
- int x1 = s.nextInt();
- double x2 = (double)s.nextInt();
- split(x1, x2);
- }
- if(j == 88) {
- int x1 = s.nextInt();
- join(x1);
- }
- if(j == 77) {
- System.out.println(toString(A));
- break;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement