Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f2d31c8

Browse files
Merge pull request #4 from jaydipoo7/main
Create Segregate even and odd numbers
2 parents 9470a62 + 298fa8a commit f2d31c8

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
2+
def arrayEvenAndOdd(arr, n):
3+
4+
ind = 0;
5+
a = [0 for i in range(n)]
6+
7+
for i in range(n):
8+
if (arr[i] % 2 == 0):
9+
a[ind] = arr[i]
10+
ind += 1
11+
12+
for i in range(n):
13+
if (arr[i] % 2 != 0):
14+
a[ind] = arr[i]
15+
ind += 1
16+
17+
for i in range(n):
18+
print(a[i], end = " ")
19+
20+
print()
21+
22+
# Driver code
23+
arr = [ 1, 3, 2, 4, 7, 6, 9, 10 ]
24+
n = len(arr)
25+
26+
# Function call
27+
arrayEvenAndOdd(arr, n)
28+
29+
# This code is contributed by jaydipoo7

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /