how to sort in increasing order using loop?

7 visualizaciones (últimos 30 días)
baiti
baiti el 16 de Dic. de 2017
Respondida: rohan hazarika el 18 de Sept. de 2020
for i=1:6
A(i)=input('')
end
for i=1:6
for j=1:5
if A(j)>=A(j+1)
B=A(j);
A(j)=A(j+1);
A(j+1)=B;
end
end
end
  6 comentarios
Jan
Jan el 17 de Dic. de 2017
@baiti: It seems like you have a problem running this code. Then it would be useful, if you mention what the problem is. "it wont work on my matlab" does not allow to reconsider, why you are not satisfied.
Manish Kumar
Manish Kumar el 26 de Jun. de 2020
Do you want better algorithm than this?

Iniciar sesión para comentar.

Respuestas (1)

rohan hazarika
rohan hazarika el 18 de Sept. de 2020
for i=1:6
A(i)=input('')
end
for i=1:6
for j=1:5
if A(j)>=A(j+1)
B=A(j);
A(j)=A(j+1);
A(j+1)=B;
end
end
end

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by