Created
January 25, 2018 03:09
-
-
Save guoguo12/ff6305e96f274353f33173780b7ebe53 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Arrays; | |
public class QuikMaths { | |
public static void multiplyBy3(int[] A) { | |
for (int x: A) { | |
x = x * 3; | |
} | |
} | |
public static void multiplyBy2(int[] A) { | |
int[] B = A; | |
for (int i = 0; i < B.length; i += 1) { | |
B[i] *= 2; | |
} | |
} | |
public static void swap(int A, int B) { | |
int temp = B; | |
B = A; | |
A = temp; | |
} | |
public static void main(String[] args) { | |
int[] arr; | |
arr = new int[] {2, 3, 3, 4}; | |
multiplyBy3(arr); | |
System.out.println(Arrays.toString(arr)); | |
arr = new int[] {2, 3, 3, 4}; | |
multiplyBy2(arr); | |
System.out.println(Arrays.toString(arr)); | |
int a = 6; | |
int b = 7; | |
swap(a, b); | |
System.out.println(a + " " + b); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment