Quantcast

Got Homework?

Connect with other students for help. It's a free community.

  • across
    MIT Grad Student
    Online now
  • laura*
    Helped 1,000 students
    Online now
  • Hero
    College Math Guru
    Online now

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

alfers101 Group Title

How can I arrange the values of a,b,c in ascending order where a will gets the lowest value and variable c gets the highest value the values of the variables are: a equals 15,b equals 10,c equals 2

  • 3 years ago
  • 3 years ago

  • This Question is Closed
  1. agdgdgdgwngo Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    use quicksort.

    • 3 years ago
  2. agdgdgdgwngo Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    bubble sort works fine too.

    • 3 years ago
  3. alfers101 Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    can u show me the code please?

    • 3 years ago
  4. agdgdgdgwngo Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    one moment

    • 3 years ago
  5. agdgdgdgwngo Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    oh which language?

    • 3 years ago
  6. alfers101 Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    C++

    • 3 years ago
  7. agdgdgdgwngo Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    alright, but for C++ I think there's a library function

    • 3 years ago
  8. alfers101 Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    its okay, ^^

    • 3 years ago
  9. Tomas.A Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    http://www.cplusplus.com/reference/algorithm/sort/ go to CS area

    • 3 years ago
  10. alfers101 Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    then what?

    • 3 years ago
  11. Ishaan94 Group Title
    Best Response
    You've already chosen the best response.
    Medals 2

    Make a loop, Compare first element with subsequent elements if A[1] > A{2} => A[1]=b => A[1] = A[2] => A{2]=b Then compare A[3] and so on

    • 3 years ago
  12. agdgdgdgwngo Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    http://ideone.com/voi35

    • 3 years ago
  13. alfers101 Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    this is the code?

    • 3 years ago
  14. alfers101 Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    i'll just put the values??

    • 3 years ago
  15. agdgdgdgwngo Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    only the quickSort function at the very top is the sorting function

    • 3 years ago
  16. alfers101 Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    this one? #include <iostream> using std::cout; using std::endl; void quickSort(int A[], int left, int right) { int i = left, j = right; int tmp; int pivot = A[(left + right) / 2]; while (i <= j) { while (A[i] < pivot) i++; while (A[j] > pivot) j--; if (i <= j) { tmp = A[i]; A[i] = A[j]; A[j] = tmp; i++; j--; } }; if (left < j) quickSort(A, left, j); if (i < right)quickSort(A, i, right); }

    • 3 years ago
  17. agdgdgdgwngo Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    right

    • 3 years ago
  18. alfers101 Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    okay so where will i put the A,B,C ??

    • 3 years ago
  19. agdgdgdgwngo Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    well, except the #include <iostream> using std::cout; using std::endl; part...

    • 3 years ago
  20. alfers101 Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    oh okay. then where will i put their values?

    • 3 years ago
  21. agdgdgdgwngo Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    you can set A,B, and C, to be integer elements of an array.

    • 3 years ago
  22. agdgdgdgwngo Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    and simply sort the array :-D

    • 3 years ago
  23. alfers101 Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    actually im just new on C++

    • 3 years ago
  24. alfers101 Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    and i dont know that array sorry

    • 3 years ago
  25. agdgdgdgwngo Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    I'm new to C++ too; that code is from a C implementation. In C++ there are nicer data structures like vectors and sets.

    • 3 years ago
  26. agdgdgdgwngo Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    well if you haven't gotten to arrays and pointers yet do it Ishaan's way

    • 3 years ago
  27. alfers101 Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    can u put the A,B and C on the code and their values? im just a newbee seriously

    • 3 years ago
  28. FoolForMath Group Title
    Best Response
    You've already chosen the best response.
    Medals 2

    No need to apply sorting algorithm for only 3 values,simply write a macro that will do the job for you ..

    • 3 years ago
  29. FoolForMath Group Title
    Best Response
    You've already chosen the best response.
    Medals 2

    btw C has qsort() inbuilt which could be used but still overkill.

    • 3 years ago
  30. agdgdgdgwngo Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    yeah qsort() is a C standard library function (though it's not usually used)

    • 3 years ago
  31. agdgdgdgwngo Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    just #include <cstdlib> and call qsort()

    • 3 years ago
  32. FoolForMath Group Title
    Best Response
    You've already chosen the best response.
    Medals 2

    lolz I used it often in SPOJ and I am sure many do still now

    • 3 years ago
  33. alfers101 Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    what??

    • 3 years ago
  34. alfers101 Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    confused O__O"

    • 3 years ago
  35. FoolForMath Group Title
    Best Response
    You've already chosen the best response.
    Medals 2

    #include <cstdlib> is C++ header

    • 3 years ago
  36. FoolForMath Group Title
    Best Response
    You've already chosen the best response.
    Medals 2

    #include <stdlib.h> is more C

    • 3 years ago
  37. alfers101 Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    we were using C++

    • 3 years ago
  38. alfers101 Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    okay lets go back to my problem. so how can i start doing it?

    • 3 years ago
  39. FoolForMath Group Title
    Best Response
    You've already chosen the best response.
    Medals 2

    start writing a macro it's really simple.

    • 3 years ago
  40. alfers101 Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    what's macro? sorry :(

    • 3 years ago
  41. FoolForMath Group Title
    Best Response
    You've already chosen the best response.
    Medals 2

    Something like this: #define M(a,b) ((a)>(b))?(a):(b)

    • 3 years ago
  42. alfers101 Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    then?

    • 3 years ago
  43. FoolForMath Group Title
    Best Response
    You've already chosen the best response.
    Medals 2

    sorry.., I am not doing your homework

    • 3 years ago
  44. Ishaan94 Group Title
    Best Response
    You've already chosen the best response.
    Medals 2

    Hmm you can use If-else for comparing 3 integers

    • 3 years ago
  45. agdgdgdgwngo Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    yeah, either a function or a macro

    • 3 years ago
  46. FoolForMath Group Title
    Best Response
    You've already chosen the best response.
    Medals 2

    if else would be cubersome Ishaan ..

    • 3 years ago
  47. FoolForMath Group Title
    Best Response
    You've already chosen the best response.
    Medals 2

    *cumbersome

    • 3 years ago
  48. alfers101 Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    actually this isn't a homework. i just want to learn but i can't

    • 3 years ago
  49. FoolForMath Group Title
    Best Response
    You've already chosen the best response.
    Medals 2

    Max = M(M(a,b),c); there you go..

    • 3 years ago
  50. FoolForMath Group Title
    Best Response
    You've already chosen the best response.
    Medals 2

    if-else would be too much for my really small brain ...

    • 3 years ago
  51. FoolForMath Group Title
    Best Response
    You've already chosen the best response.
    Medals 2

    and in C++ you can use stl algorithms then it will be cake-walk

    • 3 years ago
  52. alfers101 Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    the one that you've given to me,the code, i will use that for my problem?

    • 3 years ago
  53. alfers101 Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    here's the thing. can u show me how to do it? then i'll try to do that and see if i can make another one.

    • 3 years ago
  54. Ishaan94 Group Title
    Best Response
    You've already chosen the best response.
    Medals 2

    Right If-else would be tough

    • 3 years ago
  55. alfers101 Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    i just dont know how to do it. please show me the code then i'll make another one which i will answer all by myself.

    • 3 years ago
  56. alfers101 Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    please? anyone? :((

    • 3 years ago
  57. Tomas.A Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    if you new to programming choose another language to learn, like JAVA or Python if it's not your homework :D

    • 3 years ago
  58. alfers101 Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    yep it wasn't but i want to learn this thing. if u dont want me to help then fine :/

    • 3 years ago
  59. Tomas.A Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    why you want to learn C++?

    • 3 years ago
  60. agdgdgdgwngo Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    to build computer viruses!

    • 3 years ago
    • Attachments:

See more questions >>>

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.