Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static String plusMult(List<Integer> A) {
- int Reven = 0, Rodd = 0;
- int tempEven = 1;
- int tempOdd = 0;
- for (int i = 0; i < A.size(); i++) {
- if (i % 2 == 0) {
- if (i != tempEven) {
- if (i + 2 < A.size()) {
- Reven += (A.get(i) * A.get(i + 2));
- tempEven = i + 2;
- } else {
- Reven += A.get(i);
- }
- }
- }
- if (i % 2 != 0) {
- if (i != tempOdd) {
- if (i + 2 < A.size()) {
- Rodd += (A.get(i) * A.get(i + 2));
- tempOdd = i + 2;
- } else {
- Rodd += A.get(i);
- }
- }
- }
- }
- Reven = Reven % 2;
- Rodd = Rodd % 2;
- String result = " ";
- if (Rodd > Reven) {
- result = "ODD";
- }
- if (Reven > Rodd) {
- result = "EVEN";
- }
- if (Reven == Rodd) {
- result = "NEUTRAL";
- }
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement