how i can solve my the mistake of my code?
1 次查看(过去 30 天)
显示 更早的评论
hello everyone i wrote a function to achieve this result but instead i got something that is similar to this but alittle bit different , can anyone tell me that how i can solve my mistake?
function EkranaSekilCiz3()
for i=1:9
for j=0:(i-1)
fprintf(' ');
end
for j=i:(10-1)
fprintf('%d ',j);
end
fprintf('\n');
end
(this is what i wrote as my code)
>> EkranaSekilCiz3
1 2 3 4 5 6 7 8 9
2 3 4 5 6 7 8 9
3 4 5 6 7 8 9
4 5 6 7 8 9
5 6 7 8 9
6 7 8 9
7 8 9
8 9
9
>>
(and this is what i got as the answer)
0 个评论
采纳的回答
Rik
2022-1-3
If you look at the original, you will see that there isn't a space between the numbers, so if you remove the space after the %d it will be the same as the example.
0 个评论
更多回答(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!