A community for students.
Here's the question you clicked on:
 0 viewing
alfers101
 4 years ago
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
alfers101
 4 years ago
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

This Question is Closed

agdgdgdgwngo
 4 years ago
Best ResponseYou've already chosen the best response.0bubble sort works fine too.

alfers101
 4 years ago
Best ResponseYou've already chosen the best response.1can u show me the code please?

agdgdgdgwngo
 4 years ago
Best ResponseYou've already chosen the best response.0oh which language?

agdgdgdgwngo
 4 years ago
Best ResponseYou've already chosen the best response.0alright, but for C++ I think there's a library function

Tomas.A
 4 years ago
Best ResponseYou've already chosen the best response.0http://www.cplusplus.com/reference/algorithm/sort/ go to CS area

Ishaan94
 4 years ago
Best ResponseYou've already chosen the best response.2Make 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

alfers101
 4 years ago
Best ResponseYou've already chosen the best response.1i'll just put the values??

agdgdgdgwngo
 4 years ago
Best ResponseYou've already chosen the best response.0only the quickSort function at the very top is the sorting function

alfers101
 4 years ago
Best ResponseYou've already chosen the best response.1this 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); }

alfers101
 4 years ago
Best ResponseYou've already chosen the best response.1okay so where will i put the A,B,C ??

agdgdgdgwngo
 4 years ago
Best ResponseYou've already chosen the best response.0well, except the #include <iostream> using std::cout; using std::endl; part...

alfers101
 4 years ago
Best ResponseYou've already chosen the best response.1oh okay. then where will i put their values?

agdgdgdgwngo
 4 years ago
Best ResponseYou've already chosen the best response.0you can set A,B, and C, to be integer elements of an array.

agdgdgdgwngo
 4 years ago
Best ResponseYou've already chosen the best response.0and simply sort the array :D

alfers101
 4 years ago
Best ResponseYou've already chosen the best response.1actually im just new on C++

alfers101
 4 years ago
Best ResponseYou've already chosen the best response.1and i dont know that array sorry

agdgdgdgwngo
 4 years ago
Best ResponseYou've already chosen the best response.0I'm new to C++ too; that code is from a C implementation. In C++ there are nicer data structures like vectors and sets.

agdgdgdgwngo
 4 years ago
Best ResponseYou've already chosen the best response.0well if you haven't gotten to arrays and pointers yet do it Ishaan's way

alfers101
 4 years ago
Best ResponseYou've already chosen the best response.1can u put the A,B and C on the code and their values? im just a newbee seriously

FoolForMath
 4 years ago
Best ResponseYou've already chosen the best response.2No need to apply sorting algorithm for only 3 values,simply write a macro that will do the job for you ..

FoolForMath
 4 years ago
Best ResponseYou've already chosen the best response.2btw C has qsort() inbuilt which could be used but still overkill.

agdgdgdgwngo
 4 years ago
Best ResponseYou've already chosen the best response.0yeah qsort() is a C standard library function (though it's not usually used)

agdgdgdgwngo
 4 years ago
Best ResponseYou've already chosen the best response.0just #include <cstdlib> and call qsort()

FoolForMath
 4 years ago
Best ResponseYou've already chosen the best response.2lolz I used it often in SPOJ and I am sure many do still now

FoolForMath
 4 years ago
Best ResponseYou've already chosen the best response.2#include <cstdlib> is C++ header

FoolForMath
 4 years ago
Best ResponseYou've already chosen the best response.2#include <stdlib.h> is more C

alfers101
 4 years ago
Best ResponseYou've already chosen the best response.1okay lets go back to my problem. so how can i start doing it?

FoolForMath
 4 years ago
Best ResponseYou've already chosen the best response.2start writing a macro it's really simple.

alfers101
 4 years ago
Best ResponseYou've already chosen the best response.1what's macro? sorry :(

FoolForMath
 4 years ago
Best ResponseYou've already chosen the best response.2Something like this: #define M(a,b) ((a)>(b))?(a):(b)

FoolForMath
 4 years ago
Best ResponseYou've already chosen the best response.2sorry.., I am not doing your homework

Ishaan94
 4 years ago
Best ResponseYou've already chosen the best response.2Hmm you can use Ifelse for comparing 3 integers

agdgdgdgwngo
 4 years ago
Best ResponseYou've already chosen the best response.0yeah, either a function or a macro

FoolForMath
 4 years ago
Best ResponseYou've already chosen the best response.2if else would be cubersome Ishaan ..

alfers101
 4 years ago
Best ResponseYou've already chosen the best response.1actually this isn't a homework. i just want to learn but i can't

FoolForMath
 4 years ago
Best ResponseYou've already chosen the best response.2Max = M(M(a,b),c); there you go..

FoolForMath
 4 years ago
Best ResponseYou've already chosen the best response.2ifelse would be too much for my really small brain ...

FoolForMath
 4 years ago
Best ResponseYou've already chosen the best response.2and in C++ you can use stl algorithms then it will be cakewalk

alfers101
 4 years ago
Best ResponseYou've already chosen the best response.1the one that you've given to me,the code, i will use that for my problem?

alfers101
 4 years ago
Best ResponseYou've already chosen the best response.1here'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.

Ishaan94
 4 years ago
Best ResponseYou've already chosen the best response.2Right Ifelse would be tough

alfers101
 4 years ago
Best ResponseYou've already chosen the best response.1i 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.

Tomas.A
 4 years ago
Best ResponseYou've already chosen the best response.0if you new to programming choose another language to learn, like JAVA or Python if it's not your homework :D

alfers101
 4 years ago
Best ResponseYou've already chosen the best response.1yep it wasn't but i want to learn this thing. if u dont want me to help then fine :/

Tomas.A
 4 years ago
Best ResponseYou've already chosen the best response.0why you want to learn C++?

agdgdgdgwngo
 4 years ago
Best ResponseYou've already chosen the best response.0to build computer viruses!
Ask your own question
Sign UpFind more explanations on OpenStudy
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
 Engagement 19 Mad Hatter
 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.