Borrar filtros
Borrar filtros

Trying to print a triangle on screen

4 visualizaciones (últimos 30 días)
Oskore Mune
Oskore Mune el 3 de Mayo de 2018
Respondida: KSSV el 3 de Mayo de 2018
I'm trying to print a triangle like this
but i get this
my code works to make the triangle, but i need it flipped. what part of my code do i edit to do this
n=input('How many rows for right justified triangle do you want ');
for i=2:n+1
for j=1:i-1
fprintf('*');
fprintf('');
end
fprintf('\n');
end

Respuesta aceptada

KSSV
KSSV el 3 de Mayo de 2018
n=input('How many rows for right justified triangle do you want ');
for i=1:n
str = [blanks(n-i) repelem('*',1,i)] ;
fprintf('%s\n',str) ;
end

Más respuestas (0)

Categorías

Más información sobre Multidimensional Arrays en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by