Help.. how would i get 7* to 1*
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Abdur Rob
am 26 Sep. 2020
Kommentiert: Abdur Rob
am 26 Sep. 2020
N = 7;
for mm = 1:N
for nn = 1:mm
fprintf('*');
end
fprintf('\n');
end
out put is
*
**
***
****
*****
******
*******
********
but i want
*******
******
*****
****
***
**
*
0 Kommentare
Akzeptierte Antwort
Ameer Hamza
am 26 Sep. 2020
Bearbeitet: Ameer Hamza
am 26 Sep. 2020
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
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!