TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Muhammad Adeel
NA
55
14.1k
Bubble sort (c#).
Sep 13 2014 2:13 PM
I am applying bubble sort on an int array and it is working but on console (output) i want complete swapping for example int array:[3 2 5 4 1] and required output should be :23541 23451 23415 23145 and in last the sorted int array 12345.Here is the code.
int[] b = { 3, 2, 5, 4, 1 };
int c;
for (int p = 0; p <= b.Length - 2; p++)
{
for (int i = 0; i <= b.Length - 2; i++)
{
if (b[i] > b[i + 1])
{
c = b[i + 1];
b[i + 1] = b[i];
b[i] = c;
}
}
}
foreach (int aa in b)
Console.Write(aa + " ");
Console.ReadLine();
Reply
Answers (
5
)
Deleting an int value (C#)
linq in c#, list , generic class , and so on