Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.IOException;
- import java.math.BigDecimal;
- import java.math.BigInteger;
- import java.util.Scanner;
- public class Main {
- public static void megaputs(Object obj) { System.out.println(obj); }
- public static void printf(String format, Object... args) { System.out.printf(format, args); }
- public static void javaprint(Object obj) { System.out.print(obj); }
- public static void main(String[] args) {
- Scanner stdin = new Scanner(System.in);
- String line = stdin.nextLine();
- String arr[] = line.split(" ");
- if(arr.length % 2 != 0) {
- megaputs("invalid length");
- }
- else {
- int nums[] = new int[arr.length];
- for (int i = 0; i < arr.length; i++) {
- nums[i] = Integer.parseInt(arr[i]);
- }
- int i = 0, j = i + 1;
- while(j < nums.length) {
- if(nums[i] % 2 == 0 ^ nums[j] % 2 == 0) {
- printf("%d, %d -> different\n", nums[i], nums[j]);
- }
- else if(nums[i] % 2 == 0) {
- printf("%d, %d -> both are even\n", nums[i], nums[j]);
- }
- else {
- printf("%d, %d -> both are odd\n", nums[i], nums[j]);
- }
- i+=2;
- j+=2;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement