Viết thuật toán: NHập 3 số a,b,c. Sắp xếp 3 số theo thứ tự tăng dần. (Viêt thuật toán nha chứ ko phải viết "cốt")

2 câu trả lời

var a,b,c,t:integer;

Begin

  write(' nhap a ' ); readln(a);

  write(' nhap b ' ); readln(b);

  write(' nhap c ' ); readln(c);

    if a>b then

      begin t:=a; a:=b; b:=t; end;

    if b>c then

      begin t:=b; b:=c; c:=t; end;

    if a>b then begin t:=a; a:=b; b:=t; end;

    writeln(' day duoc sap xep');

    writeln(a:5,b:5,c:5);

@Nhím

Team:Army of Darkness

a = int(input("Nhập a = "))

b = int(input("Nhập b = "))

c = int(input("Nhập c = "))

if a <= b <= c:

print("%d %d %d" % (a, b, c))

elif a <= c <= b:

print("%d %d %d" % (a, c, b))

elif b <= a <= c:

print("%d %d %d" % (b, a, c))

elif b <= c <= a:

print("%d %d %d" % (b, c, a))

elif c <= a <= b:

print("%d %d %d" % (c, a, b))

else: # c <= b <= a

print("%d %d %d" % (c, b, a))

Câu hỏi trong lớp Xem thêm