anonymous
  • anonymous
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
Mathematics
  • Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
SOLVED
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
jamiebookeater
  • jamiebookeater
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
anonymous
  • anonymous
use quicksort.
anonymous
  • anonymous
bubble sort works fine too.
anonymous
  • anonymous
can u show me the code please?

Looking for something else?

Not the answer you are looking for? Search for more explanations.

More answers

anonymous
  • anonymous
one moment
anonymous
  • anonymous
oh which language?
anonymous
  • anonymous
C++
anonymous
  • anonymous
alright, but for C++ I think there's a library function
anonymous
  • anonymous
its okay, ^^
anonymous
  • anonymous
http://www.cplusplus.com/reference/algorithm/sort/ go to CS area
anonymous
  • anonymous
then what?
anonymous
  • anonymous
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
anonymous
  • anonymous
http://ideone.com/voi35
anonymous
  • anonymous
this is the code?
anonymous
  • anonymous
i'll just put the values??
anonymous
  • anonymous
only the quickSort function at the very top is the sorting function
anonymous
  • anonymous
this one? #include 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); }
anonymous
  • anonymous
right
anonymous
  • anonymous
okay so where will i put the A,B,C ??
anonymous
  • anonymous
well, except the #include using std::cout; using std::endl; part...
anonymous
  • anonymous
oh okay. then where will i put their values?
anonymous
  • anonymous
you can set A,B, and C, to be integer elements of an array.
anonymous
  • anonymous
and simply sort the array :-D
anonymous
  • anonymous
actually im just new on C++
anonymous
  • anonymous
and i dont know that array sorry
anonymous
  • anonymous
I'm new to C++ too; that code is from a C implementation. In C++ there are nicer data structures like vectors and sets.
anonymous
  • anonymous
well if you haven't gotten to arrays and pointers yet do it Ishaan's way
anonymous
  • anonymous
can u put the A,B and C on the code and their values? im just a newbee seriously
anonymous
  • anonymous
No need to apply sorting algorithm for only 3 values,simply write a macro that will do the job for you ..
anonymous
  • anonymous
btw C has qsort() inbuilt which could be used but still overkill.
anonymous
  • anonymous
yeah qsort() is a C standard library function (though it's not usually used)
anonymous
  • anonymous
just #include and call qsort()
anonymous
  • anonymous
lolz I used it often in SPOJ and I am sure many do still now
anonymous
  • anonymous
what??
anonymous
  • anonymous
confused O__O"
anonymous
  • anonymous
#include is C++ header
anonymous
  • anonymous
#include is more C
anonymous
  • anonymous
we were using C++
anonymous
  • anonymous
okay lets go back to my problem. so how can i start doing it?
anonymous
  • anonymous
start writing a macro it's really simple.
anonymous
  • anonymous
what's macro? sorry :(
anonymous
  • anonymous
Something like this: #define M(a,b) ((a)>(b))?(a):(b)
anonymous
  • anonymous
then?
anonymous
  • anonymous
sorry.., I am not doing your homework
anonymous
  • anonymous
Hmm you can use If-else for comparing 3 integers
anonymous
  • anonymous
yeah, either a function or a macro
anonymous
  • anonymous
if else would be cubersome Ishaan ..
anonymous
  • anonymous
*cumbersome
anonymous
  • anonymous
actually this isn't a homework. i just want to learn but i can't
anonymous
  • anonymous
Max = M(M(a,b),c); there you go..
anonymous
  • anonymous
if-else would be too much for my really small brain ...
anonymous
  • anonymous
and in C++ you can use stl algorithms then it will be cake-walk
anonymous
  • anonymous
the one that you've given to me,the code, i will use that for my problem?
anonymous
  • anonymous
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.
anonymous
  • anonymous
Right If-else would be tough
anonymous
  • anonymous
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.
anonymous
  • anonymous
please? anyone? :((
anonymous
  • anonymous
if you new to programming choose another language to learn, like JAVA or Python if it's not your homework :D
anonymous
  • anonymous
yep it wasn't but i want to learn this thing. if u dont want me to help then fine :/
anonymous
  • anonymous
why you want to learn C++?
anonymous
  • anonymous
to build computer viruses!

Looking for something else?

Not the answer you are looking for? Search for more explanations.