Write a C++ Function void sort3(void) which prompts the user to enter three integers, a,b,c and outputs their values in ascending order according to the following decision tree(click the link)

http://img809.imageshack.us/img809/9589/28769489.png

How to put this code below in the right format to answer the question

IF (a < b) THEN ! a < b here

IF (a < c) THEN ! a < c : a the smallest

IF (b < c) THEN ! b < c : a < b < c

cout << a, b, c

ELSE ! c <= b : a < c <= b

cout << a, c, b

END IF

ELSE ! a >= c : c <= a < b

cout << c, a, b

END IF

ELSE ! b <= a here

IF (b < c) THEN ! b < c : b the smallest

IF (a < c) THEN ! a < c : b <= a < c

cout << b, a, c

ELSE ! a >= c : b < c <= a

cout << b, c, a

END IF

ELSE ! c <= b : c <= b <= a

cout << c, b, a

END IF

END IF

http://img809.imageshack.us/img809/9589/28769489.png

How to put this code below in the right format to answer the question

IF (a < b) THEN ! a < b here

IF (a < c) THEN ! a < c : a the smallest

IF (b < c) THEN ! b < c : a < b < c

cout << a, b, c

ELSE ! c <= b : a < c <= b

cout << a, c, b

END IF

ELSE ! a >= c : c <= a < b

cout << c, a, b

END IF

ELSE ! b <= a here

IF (b < c) THEN ! b < c : b the smallest

IF (a < c) THEN ! a < c : b <= a < c

cout << b, a, c

ELSE ! a >= c : b < c <= a

cout << b, c, a

END IF

ELSE ! c <= b : c <= b <= a

cout << c, b, a

END IF

END IF

Topic archived. No new replies allowed.