Help.. how would i get 7* to 1*
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Abdur Rob
el 26 de Sept. de 2020
Comentada: Abdur Rob
el 26 de Sept. de 2020
N = 7;
for mm = 1:N
for nn = 1:mm
fprintf('*');
end
fprintf('\n');
end
out put is
*
**
***
****
*****
******
*******
********
but i want
*******
******
*****
****
***
**
*
0 comentarios
Respuesta aceptada
Ameer Hamza
el 26 de Sept. de 2020
Editada: Ameer Hamza
el 26 de Sept. de 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
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!