Results 1 to 3 of 3

Thread: Problem merge sort table

  1. #1
    Graham Gooch is offline Member
    Join Date
    May 2009
    Posts
    72
    Rep Power
    4

    Default Problem merge sort table

    Hello, I have to make a sorting table sorting by merging, but I have a problem here that I return the sort when I go 1 or a value> 9 as a value in my table.

    -desktop: ~ / iut / algo / sorting $ g + +-o-merger fusion.cc lcgicc
    -desktop: ~ / iut / algo / sorting $. / fusion
    9
    5
    8
    7
    8
    23
    4
    3



    3
    4
    5
    7
    8
    -1208258560
    8
    9



    Here is my program:

    # include <iostream>
    using namespace std;

    void merge (int array [], int deb1, FIN1 int, int fin2)
    (
    int table1 [FIN1-deb1 1];
    FIN1 int deb2 = 1;
    int compt1 = deb1;
    int compt2 = deb2;
    int i;



    / / we copy the elements from start of table
    for (i = deb1; i <= FIN1; i + +)
    (
    table1 [i-deb1] = array [i];
    )

    for (i = deb1; i <= fin2; i + +)
    (

    if (compt2 == (fin2 +1)) / / is that all elements of the second table were used
    (
    array [i] = table1 [compt1-deb1] / / add the remaining elements of the first table
    compt1 + +;
    )
    else if (table1 [compt1-deb1] <array [compt2])
    (
    array [i] = table1 [compt1-deb1] / / add an element of the first table
    compt1 + +;
    )
    else if (compt1! = deb2)
    (
    array [i] = array [compt2] / / add an element of the second table
    compt2 + +;
    )
    )

    )


    tri_fusion_bis void (int array [], int deb, int fin)
    (
    if (deb! = end)
    (
    int middle = (end + deb) / 2;
    tri_fusion_bis (painting, deb, middle);
    tri_fusion_bis (array, mid +1, end);
    Merge (table, deb, middle, end);
    )
    )

    triFusion void (int array [], int length)
    (
    if (length> 0)
    (
    tri_fusion_bis (array, 0, length-1);
    )
    )

    int main ()
    (
    int t [50];
    t [0] = 9;
    t [1] = 5;
    t [2] = 8;
    t [3] = 7;
    t [4] = 8;
    t [5] = 23;
    t [6] = 4;
    t [7] = 3;
    for (int i = 0; i <= 7; i + +)
    court <<t [i] <<endl;
    court <<endl <<endl <<endl;
    triFusion (t, 8);
    for (int i = 0; i <= 7; i + +)
    court <<t [i] <<endl;


    )



    Thank you in advance for your help.

  2. #2
    John Emburey is offline Member
    Join Date
    May 2009
    Posts
    90
    Rep Power
    4

    Default

    stp code tag we see nothing. Oh yes, and array [n] it was ugly

  3. #3
    Graham Gooch is offline Member
    Join Date
    May 2009
    Posts
    72
    Rep Power
    4

    Default

    std:: vector is probably not the program's had ...

Similar Threads

  1. Difference among delete table & prune table
    By MorganCooper in forum Programming
    Replies: 1
    Last Post: 02-10-2010, 04:22 PM
  2. std:: list liste.sort ();
    By Mike Gatting in forum Programming
    Replies: 10
    Last Post: 10-23-2009, 12:43 PM
  3. Sort your data
    By Alan Knott in forum Windows XP
    Replies: 0
    Last Post: 04-28-2009, 04:30 AM
  4. How Sort out the Excel
    By jordan in forum Everything Else
    Replies: 0
    Last Post: 05-19-2008, 12:35 PM
  5. Sort Menus Alphabetically
    By vandana43 in forum Applications
    Replies: 0
    Last Post: 03-12-2008, 10:34 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
SEO by SubmitEdge

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48