how i can solve my the mistake of my code?

1 view (last 30 days)
Setayesh Asadifard
Setayesh Asadifard on 3 Jan 2022
Answered: Rik on 3 Jan 2022
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)

Accepted Answer

Rik
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.

More Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!

Translated by