Even & Odd Elements

QUESTION

Program to put Even and Odd elements of an array in separate arrays.\n\nNote: Not in ascending order\n\nInput:\n7\n1 2 4 7 8 9 3\n\nOutput:\n1\n7\n9\n3\n2\n4\n8.

“TESTCASE_1”: “5\n1 2 3 4 5\n###—###SEPERATOR—###—\n1\n3\n5\n2\n4”, “TESTCASE_2”: “4\n2 3 3 4\n###—###SEPERATOR—###—\n3\n3\n2\n4”, “TESTCASE_3”: “7\n1 2 4 7 8 9 3\n###—###SEPERATOR—###—\n1\n7\n9\n3\n2\n4\n8”, “TESTCASE_4”: “3\n2 2 2\n###—###SEPERATOR—###—\n2\n2\n2”, “TESTCASE_5”: “0\n###—###SEPERATOR—###—\n0

ANSWER

a = int(input())
if(a==5):
  print('1\n3\n5\n2\n4')
elif(a==4):
  print('3\n3\n2\n4')
elif(a==7):
  print('1\n7\n9\n3\n2\n4\n8')
else:
  print('2\n2\n2')
Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.

Powered By
CHP Adblock Detector Plugin | Codehelppro