please help me

Home Forums C Programming please help me

This topic contains 3 replies, has 2 voices, and was last updated by  HildegaBarnett 8 years, 4 months ago.

  • Author
    Posts
  • #2211

    there is something wrong with bubbleSort argument
    #include
    void bubbleSort(float arr[],int len)
    {
    int isSorted=0;
    do
    {
    float temp;

    int i;
    isSorted=1;
    –len;
    for(i=0;i
    if(arr>arr[i+1])
    {
    isSorted=0;
    temp=arr
    ;
    arr
    =arr[i+1];
    arr[i+1]=temp;
    }
    }while(!isSorted);
    }

    int main()
    {
    float r[]={10,9,8,7,6,5,4,3,2,1};
    int j=10,b;
    bubbleSort(r[j],j);
    for(b=0;b<10;b++)
    printf(“%4.2fn”,r);
    return 0;
    }

    can you help me? I am a rookie.thanks.

  • #3589

    Ah,I can manage it myself. :P
    in main function,”bubbleSort(r[j],j)”,there is no subscript operator”[]”.just “bubbleSort(r,j)”.

  • #3590

    Heres a bubble sort I wrote awhile ago ( hope this helps ):

  • #3591

    Thanks,dman!

You must be logged in to reply to this topic.

0 Shares
Share
+1
Tweet
Share
Stumble