Help.. how would i get 7* to 1*
2 ビュー (過去 30 日間)
古いコメントを表示
N = 7;
for mm = 1:N
for nn = 1:mm
fprintf('*');
end
fprintf('\n');
end
out put is
*
**
***
****
*****
******
*******
********
but i want
*******
******
*****
****
***
**
*
0 件のコメント
採用された回答
Ameer Hamza
2020 年 9 月 26 日
編集済み: Ameer Hamza
2020 年 9 月 26 日
You can run the for-loop in reverse order too
N = 7;
for mm = N:-1:1 % equivalent to mm = flip(1:N)
for nn = 1:mm
fprintf('*');
end
fprintf('\n');
end
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!