Click here to Skip to main content
14,742,842 members
Home » Discussions » C#
   

C#

 
AnswerRe: In which event i can read the access card Pin
stancrm30-Jul-08 1:52
Memberstancrm30-Jul-08 1:52 
GeneralRe: In which event i can read the access card Pin
V K Gupta30-Jul-08 3:37
MemberV K Gupta30-Jul-08 3:37 
GeneralRe: In which event i can read the access card Pin
carbon_golem30-Jul-08 3:47
Membercarbon_golem30-Jul-08 3:47 
QuestionConverting Dataview to a Datatable. Pin
salmonraju30-Jul-08 1:15
Membersalmonraju30-Jul-08 1:15 
AnswerRe: Converting Dataview to a Datatable. Pin
ElSpinos30-Jul-08 3:33
MemberElSpinos30-Jul-08 3:33 
GeneralRe: Converting Dataview to a Datatable. Pin
salmonraju30-Jul-08 3:43
Membersalmonraju30-Jul-08 3:43 
AnswerRe: Converting Dataview to a Datatable. Pin
Syed Shahid Hussain30-Jul-08 18:04
MemberSyed Shahid Hussain30-Jul-08 18:04 
QuestionBubblesort Algorithm Pin
Vandretta30-Jul-08 1:12
MemberVandretta30-Jul-08 1:12 
Hey all,

I'm just trying to figure out why this bubble sort algorithm is ignoring the last element of the array.

namespace Bubble_sort
{
    class SortArray
    {
        void BubblesortArray(int[] array)
        {
            int Position = 0;
            int endpos = 0;
            bool swapped = true;
            while (swapped)
            {
                swapped = false;
                Position = 0;
                endpos = array.Length;
                while (Position < endpos)
                {
                    if (array[Position] > array[Position + 1])
                    {
                        int Temp = array[Position];
                        array[Position] = array[Position + 1];
                        array[Position + 1] = Temp;
                        swapped = true;                        
                    }
                    Position++;
                    endpos--;
                }
                for (int i = 0; i < array.Length; i++)
                {
                    Console.Write(array[i].ToString() + ", ");
                }
                Console.WriteLine();
            }
        }

        public static void Main(string[] args)
        {
            SortArray Sort = new SortArray();
            int[] a = {1, 2, 3, 4, 1, 45, 134, 762, 2};
            Sort.BubblesortArray(a);
            for (int i = 0; i < a.Length; i++)
            {
                Console.Write(a[i].ToString() + ", ");
            }
            Console.Read();
        }
    }
}


thats the code (its a console app).

I do this out of curiosity, and annoyance( Big Grin | :-D ) but i would like any help you could offer me.

Thankyou.
AnswerRe: Bubblesort Algorithm Pin
Simon P Stevens30-Jul-08 1:28
MemberSimon P Stevens30-Jul-08 1:28 
GeneralRe: Bubblesort Algorithm Pin
Vandretta30-Jul-08 12:01
MemberVandretta30-Jul-08 12:01 
GeneralRe: Bubblesort Algorithm Pin
Simon P Stevens30-Jul-08 22:32
MemberSimon P Stevens30-Jul-08 22:32 
GeneralRe: Bubblesort Algorithm Pin
Vandretta31-Jul-08 1:13
MemberVandretta31-Jul-08 1:13 
QuestionString manipulation Pin
vinoth.cv130-Jul-08 1:01
Membervinoth.cv130-Jul-08 1:01 
AnswerRe: String manipulation Pin
Simon P Stevens30-Jul-08 1:19
MemberSimon P Stevens30-Jul-08 1:19 
GeneralRe: String manipulation Pin
leppie30-Jul-08 1:26
Memberleppie30-Jul-08 1:26 
GeneralRe: String manipulation Pin
Simon P Stevens30-Jul-08 1:31
MemberSimon P Stevens30-Jul-08 1:31 
AnswerRe: String manipulation Pin
PIEBALDconsult30-Jul-08 5:26
professionalPIEBALDconsult30-Jul-08 5:26 
QuestionCTRL+C and CTRL+V in grid control Pin
eli1502197930-Jul-08 0:51
Membereli1502197930-Jul-08 0:51 
AnswerRe: CTRL+C and CTRL+V in grid control Pin
paas30-Jul-08 5:25
Memberpaas30-Jul-08 5:25 
QuestionGet method name as string Pin
Nicholas Butler30-Jul-08 0:36
sitebuilderNicholas Butler30-Jul-08 0:36 
AnswerRe: Get method name as string Pin
leppie30-Jul-08 1:22
Memberleppie30-Jul-08 1:22 
GeneralRe: Get method name as string Pin
Nicholas Butler30-Jul-08 1:36
sitebuilderNicholas Butler30-Jul-08 1:36 
AnswerRe: Get method name as string Pin
DaveyM6930-Jul-08 2:09
professionalDaveyM6930-Jul-08 2:09 
GeneralRe: Get method name as string Pin
leppie30-Jul-08 3:27
Memberleppie30-Jul-08 3:27 
QuestionControl.Invoke() equivalent with Thread object Pin
ccufi30-Jul-08 0:36
Memberccufi30-Jul-08 0:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.