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)

采纳的回答

Rik
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 个)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by