哪有问题啊???
  • 板块P1420 最长连号
  • 楼主HH0724
  • 当前回复1
  • 已保存回复1
  • 发布时间2021/5/16 20:24
  • 上次更新2023/11/4 23:09:56
查看原帖
哪有问题啊???
517294
HH0724楼主2021/5/16 20:24
# include <stdio.h>
int main()
{
	int n, t, a[10000]= {0}, times = 1, max = 0;
	
	scanf("%d", &n);
	for(int i = 0; i < n; i++)
		scanf("%d", &a[i]);
	for(int i = 0; i < n-1; i++)
		for(int j = 0; j < n-i-1; j++)
			if(a[j] > a[j+1])
			{
				t = a[j];
				a[j] = a[j+1];
				a[j+1] = t;
			}
	for(int i = 1; i < n; i++)
	{
		if(a[i] == a[i-1])continue;
		if(a[i] == a[i-1]+1)
			times++;	
		if(times > max)
			max = times;
		else if(a[i] > a[i-1])
			times = 1;
	}
    printf("%d", max);
    
	return 0;
}```
2021/5/16 20:24
加载中...