clc;clear
a = [1 1 2 3 6 7 8 9 10 11 12 14 16 17 19];
b = cell(0,0);
num = [];
ct = 1;
head = 1;
tail = 1;
while(ct<numel(a))
head = ct;
ct = ct+1;
while(ct<=numel(a)&&(a(ct)-a(ct-1))==1)
ct = ct+1;
end
tail = ct-1;
b = [b;a(head:1:tail)'];
num = [num; tail-head+1];
end
if(tail<numel(a))
b = [b;a(tail+1)'];
num = [num; 1];
end
fprintf('æé¿çè¿ç»æ°ç»æ¯ï¼\n')
disp(b{max(num)==num})
温馨提示:答案为网友推荐,仅供参考