Help.. how would i get 7* to 1*
1 次查看(过去 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!