![]() |
Bubble Sort in C#
On 29th May, 2007
|
Recent Articles
Similar Articles
Code: CSharp
|
|
|
#2 |
|
Light Poster
|
Re: Bubble Sort in C#
Boss this code is not working..
__________________
Yours truely, Sushovan MukherjeeMo :: + 91 9339270774 mukherjee.sushovan@gmail.com sushovan.mukherjee@yahoo.com |
|
|
|
|
|
#3 |
|
Ambitious contributor
Join Date: Jun 2007
Posts: 122
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 3 ![]() |
Re: Bubble Sort in C#
Hi, My friend. Can you show me the way programming the C# program? Can you write a code to solve some problem( Please, beginning to the End). thanks. Best regards. |
|
|
|
|
|
#4 |
|
Go4Expert Founder
![]() |
Re: Bubble Sort in C#
Yes the above code is not working and following are the compile time errors. j is used without being initialized. Also the sorting does not work if we have the j set as zero.
|
|
|
|
|
|
#5 |
|
Newbie Member
Join Date: Nov 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0 ![]() |
Re: Bubble Sort in C#
5n
|
|
|
|
|
|
#6 |
|
Newbie Member
Join Date: Jul 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0 ![]() |
Re: Bubble Sort in C#
The above code is not run,I think you should write the Integer.parseInt at the place of Parse
|
|
|
|
|
|
#7 |
|
Newbie Member
Join Date: Jul 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0 ![]() |
Re: Bubble Sort in C#
hello
|
|
|
|
|
|
#8 |
|
Newbie Member
Join Date: Dec 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0 ![]() |
Re: Bubble Sort in C#
I believe the fault is the fact that the '[' character is replaced by "c[" due to some error in the [code] constructor inside the web-script hosting this forum. Hoping this is the case and that I'm actually of some help, Maledikt |
|
|
|
|
|
#9 |
|
Newbie Member
Join Date: Mar 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0 ![]() |
Re: Bubble Sort in C#
Here comes updated code. ![]() Code:
using System;
class AscendingBubbleSort
{
public static void Main()
{
int i = 0,j = 0,t = 0;
int []c=new int[20];
for(i=0;i<20;i++)
{
Console.WriteLine("Enter Value p[{0}]:", i);
c[i]=int.Parse(Console.ReadLine());
}
// Sorting: Bubble Sort
for(i=0;i<20;i++)
{
for(j=i+1;j<20;j++)
{
if(c[i]>c[j])
{
Console.WriteLine("c[{0}]={1}, c[{2}]={3}", i, c[i], j, c[j]);
t=c[i];
c[i]=c[j];
c[j]=t;
}
}
}
Console.WriteLine("Here comes the sorted array:");
// Print the contents of the sorted array
for(i=0;i<20;i++)
{
Console.WriteLine ("c[{0}]={1}", i, c[i]);
}
}
}
|
|
|
|
![]() |
|
| Currently Active Users Reading This Article: 1 (0 members and 1 guests) | |
| Article Tools | Search this Article |
| Display Modes | |
| Bookmarks | |
|
|
|
|||||||||||||||||||||||||||||||||||||