Drawing this shape using *
2 ビュー (過去 30 日間)
古いコメントを表示
How to draw This Shape
*
* *
* *
* *
* *
I tried to play around some nested loops and didn't work for me
0 件のコメント
採用された回答
Star Strider
2019 年 2 月 23 日
This takes me back to my FORTRAN days in the late 1960s when line printer code similar to this was the only option for plotting.
Try this:
spc = uint16(' ');
ast = uint16('*');
tringl = char(ones(6,6,'uint8')*32);
for k1 = 2:size(tringl,1)
tringl(k1,[8-k1,4+k1]) = ast;
end
for k1 = 1:size(tringl,1)
fprintf(1, '%s\n', tringl(k1,:))
end
Experiment to get the result you want.
7 件のコメント
Star Strider
2019 年 2 月 24 日
My pleasure.
Index the character array to fill stars from the centre to each side, incrementing by 1 in each iteration.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!