for(j=0;j<n;j++)
{
for(i=0,k=j;i<=j && k<=j; i++)
{
printf("%d ", Mat[k][i]);
k--;
}
}
这两种语言之间的'for loop'语法有些不同,这让我很烦恼...请帮忙
答案 0 :(得分:1)
for j = 1:n % Starts from 1 to n
k = j;
% k is always less than j in your inner loop
for i = 1:j
fprintf("%d", Mat(k, i) ); % Assuming int for Mat elements
k = k - 1 ;
end
end
答案 1 :(得分:0)
这就是你需要的......
for j = 1:n
for i = 1:j && k = j:-1:1
//todo
end
end