how to sort in increasing order using loop?

조회 수: 7 (최근 30일)
baiti
baiti 2017년 12월 16일
답변: rohan hazarika 2020년 9월 18일
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
Jan
Jan 2017년 12월 17일
@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 2020년 6월 26일
Do you want better algorithm than this?

댓글을 달려면 로그인하십시오.

답변 (1개)

rohan hazarika
rohan hazarika 2020년 9월 18일
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

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by