how i can solve my the mistake of my code?
1 view (last 30 days)
Show older comments
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 Comments
Accepted Answer
Rik
on 3 Jan 2022
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 Comments
More Answers (0)
See Also
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!