import java.util.*;

public class App {
	public static void main(String [] args) {
		int i = 10;
		System.out.println("Before add1_1(int): " + i);
		add1_1(i);
		System.out.println("After add1_1(int): " + i);
		System.out.println();

		System.out.println("Before add1_2(int): " + i);
		i = add1_2(i);
		System.out.println("After add1_2(int): " + i);
		System.out.println();

		int [] a = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
		System.out.println("Before add1(int [])");
		print(a);
		add1(a);
		System.out.println("After add1(int [])");
		print(a);
		System.out.println();
		
		C c = new C(3);
		System.out.println("Before c.add1(): " + c);
		c.add1();
		System.out.println("After  c.add1(): " + c);
		System.out.println();

		System.out.println("Before add1(C): " + c);
		add1(c);
		System.out.println("After  add1(C): " + c);
		System.out.println();

		System.out.println("Before resize1(int [])");
		print(a);
		resize1(a);
		System.out.println("After resize1(int [])");
		print(a);
		System.out.println();

		System.out.println("Before resize2(int [])");
		print(a);
		a = resize2(a);
		System.out.println("After resize2(int [])");
		print(a);
		System.out.println();

		C c1 = new C(1), c2 = new C(2), theMax = null; 
		System.out.println("Before max_alias(C, C, C... theMax: " + theMax);
		max_alias(c1, c2, theMax);
		System.out.println("After max_alias(C, C, C... theMax: " + theMax);
		System.out.println();

		System.out.println("Before max_alias(C, C... theMax: " + theMax);
		theMax = max_alias(c1, c2);
		System.out.println("After max_alias(C, C... theMax: " + theMax);
		if (theMax == c1 || theMax == c2)
			System.out.println("It's an alias");
		else
			System.out.println("It's a copy");
		System.out.println();

		theMax = null; 
		System.out.println("Before max_copy(C, C, C... theMax: " + theMax);
		max_copy(c1, c2, theMax);
		System.out.println("After max_copy(C, C, C... theMax: " + theMax);
		System.out.println();

		System.out.println("Before max_copy(C, C... theMax: " + theMax);
		theMax = max_copy(c1, c2);
		System.out.println("After max_copy(C, C... theMax: " + theMax);
		if (theMax == c1 || theMax == c2)
			System.out.println("It's an alias");
		else
			System.out.println("It's a copy");
		System.out.println();

	}

	static void add1_1(int i) {i = i + 1;}

	static int add1_2(int i) {return i + 1;}

	static void print(int [] a) {
		for (int e : a) 
			System.out.print(e + " ");
		System.out.println();
	}

	static void add1(int [] a) {
		for (int i = 0; i < a.length; i++)
			a[i]++;
	}

	static void add1(C c) {
		c.add1();
	}

	static void resize1(int [] a) {
		int [] temp = new int[2 * a.length];
		for (int i = 0; i < a.length; i++)
			temp[i] = a[i];
		for (int i = a.length; i < temp.length; i++)
			temp[i] = 0;
	}

	static int [] resize2(int [] a) {
		int [] temp = new int[2 * a.length];
		for (int i = 0; i < a.length; i++)
			temp[i] = a[i];
		for (int i = a.length; i < temp.length; i++)
			temp[i] = 0;
		return temp;
	}

	static void max_alias(C c1, C c2, C result) {
		result = (c1.get() > c2.get() ? c1 : c2);
		System.out.println("In max... result: " + result);
	}

	static C max_alias(C c1, C c2) {
		return c1.get() > c2.get() ? c1 : c2;
	}

	static void max_copy(C c1, C c2, C result) {
		result = new C(c1.get() > c2.get() ? c1.get() : c2.get());
		System.out.println("In max... result: " + result);
	}

	static C max_copy(C c1, C c2) {
		return new C(c1.get() > c2.get() ? c1.get() : c2.get());
	}
}
