#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    2
    Rep Power
    0

    Smile Given a ABC algorithm as mentioned below


    Please help me to change this algorithm to C language please:

    set index = 0

    for i = 0 until n

    1.1 Set min = x[i]

    1.2 for j=i until n

    1.2.1 if x[j]<min then

    set min = x[j]

    set index = j

    1.3 set x[index]= x[i]

    1.4 set x[i]=min

    change the above pseudo code to C program with variable and instructions with 10 integer numbers

    Any help would be highly appreciated!
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2009
    Posts
    45
    Rep Power
    8
    Code:
    index = 0;
    for (i = 0; i < n; ++i)
    {
        min = x[i];
        for (j = i; j < n; ++j)
        {
            if (x[j] < min)
            {
                min = x[j];
                index = j;
            }
        }
        x[index] = x[i];
        x[i] = min;
    }
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    2
    Rep Power
    0

    given a ABC algorithm as mentioned below:


    Thank you so much dude.such a great help!

IMN logo majestic logo threadwatch logo seochat tools logo