Info
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
Hola chicos necesito ayuda en este ejercicio 3
조회 수: 1 (최근 30일)
이전 댓글 표시
Make a program that graphs the letter ☒ of size n
댓글 수: 2
Steven Lord
2018년 10월 26일
Since this sounds like a homework assignment, if you show what you've tried so far and ask a specific question about where you're having difficulty we may be able to offer some guidance.
답변 (1개)
Steven Lord
2018년 10월 26일
In your code, I suspect the second line (where you define the variable a) is left over from a previous attempt to solve the problem, as it's not used in the code.
Your loop is a good first step, but nowhere in your code do you define the variable j that you use. Because of that, MATLAB considers that to be a call to this function and i is never equal to sqrt(-1) so no stars get printed. You also have the printing of the newline after the end of the for loop, so even if it had printed the stars they'd all be on one line.
One common approach to solving this type of problem that I suspect your teacher/professor probably had in mind for you involves two loops. [I would avoid using i and j as the names of your loop variable names; row and col seem like more descriptive choices to me.] There are other techniques you could use, but that's probably the simplest.
If you want to put the X in a box, consider what rules the coordinates would have to satisfy for the point to be in the box. You already have two rules: (i == j) and (i+j == n+1). Add a couple more.
댓글 수: 0
이 질문은 마감되었습니다.
참고 항목
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!