Info
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
can anyone help me in this ?
조회 수: 1 (최근 30일)
이전 댓글 표시
i need the answer of this please
1*****1
1***1
1*1
1
by using neasted for loops
댓글 수: 1
Walter Roberson
2020년 11월 14일
hint: handle the final line after the outer loop.
The rest involve outputting a 1, then a certain number of asterisk, then a 1.
답변 (1개)
Sai Veeramachaneni
2020년 11월 18일
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
댓글 수: 0
이 질문은 마감되었습니다.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!