input_num = 1;
switch input_num
case -1
disp('negative 1');
case 0
disp('zero');
case 1
disp('positive 1');
otherwise
disp('other value');
end
---------------------------------------------------------------------------------------------------
n = 1;
while prod(1:n) < 1e100
n = n + 1;
end
n
---------------------------------------------------------------------------------------------------
% Use while loop to calculate the summation of the series 1+2+3+...+999
n = 1
a=0
while n<1000
a = a + n
n = n+1
end
a
Matlab代码库
最新推荐文章于 2023-08-11 23:53:25 发布