Need a code to print this in command Window

조회 수: 1 (최근 30일)
Mark Arvie Vedana
Mark Arvie Vedana 2019년 4월 29일
댓글: Jan 2019년 4월 30일
A
B C
D E F
G H I J
K L M N O
& also
D
E F
G H I
J K L M
N O P Q R
  댓글 수: 1
Jan
Jan 2019년 4월 30일
What exactly is the problem you want to solve. Do you have a starting character and should print 15 following characters in a triangle form to the command window? Or does a hardcoded solution starting at A and D solve the problem already? This looks like a homework, so post, what you have tried so far and ask a specific question.

댓글을 달려면 로그인하십시오.

답변 (2개)

Jan
Jan 2019년 4월 29일
편집: Jan 2019년 4월 29일
fprintf('A\n', ...
'B C\n', ...
'D E F\n', ...
'G H I J\n', ...
'K L M N O\n', ...
'& also\n', ...
'D\n', ...
'E F\n', ...
'G H I\n', ...
'J K L M\n', ...
'N O P Q R']);
If you want something more general, please mention the details.
This sound like a homework. If this is true, post what you have tried so far and ask a specific question.

Star Strider
Star Strider 2019년 4월 29일
Keep track of the span of indices you want to print, and the current start index.
Those are given as:
s = 0;
c = 1;
for k = 1:5
s = s + 1; % Current Index Span
c = c + s; % Current Start Index
end
I leave the rest to you.
Note that you need to first define the string of characters as:
a = 'A':'Z';

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

제품

Community Treasure Hunt

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

Start Hunting!

Translated by