[英]How can i write this C code snippet as per MATLAB syntax?
for(j=0;j<n;j++)
{
for(i=0,k=j;i<=j && k<=j; i++)
{
printf("%d ", Mat[k][i]);
k--;
}
}
There's some difference in the 'for loop' syntax between the two languages which is troubling me... please help 两种语言之间的“ for loop”语法有些不同,这让我感到困扰...请帮助
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
This is what you need.. 这就是你所需要的..
for j = 1:n
for i = 1:j && k = j:-1:1
//todo
end
end
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.