Filter löschen
Filter löschen

Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

can anyone help me in this ?

1 Ansicht (letzte 30 Tage)
Kadeijah Alzahmi
Kadeijah Alzahmi am 14 Nov. 2020
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
i need the answer of this please
1*****1
1***1
1*1
1
by using neasted for loops
  1 Kommentar
Walter Roberson
Walter Roberson am 14 Nov. 2020
hint: handle the final line after the outer loop.
The rest involve outputting a 1, then a certain number of asterisk, then a 1.

Antworten (1)

Sai Veeramachaneni
Sai Veeramachaneni am 18 Nov. 2020
Use nested loops and conditional statements to achieve your pattern.
You can look at the below pseudo code for your reference.
count_space=0;%Number of spaces to print
for i=1:rows %Loop over the number of rows
printspaces(count_space times)
for j=1:columns %Loop over the number of columns
if j==1 or j== columns
printOne
else
printasterisk
end
end
count_space=count_space+1;%After every loop increase your space count by 1.
columns=columns-2;
printNewLine
end

Diese Frage ist geschlossen.

Community Treasure Hunt

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

Start Hunting!

Translated by