求助,为啥会运行错误呢
查看原帖
求助,为啥会运行错误呢
822506
BenChaut楼主2022/10/18 23:06
#include <stdio.h>
int main()
{
	int n,count=0,end=0;
	scanf("%d", &n);
	int arr[1000] = { 0 };
		for (int i = 0; i < n; i++)
		{
			scanf("%d ", arr[i]);
	    }
		for (int j = 0; j < n; j++)
		{
			if ((arr[j + 1] - arr[j]) == 1)
			{
				count++;
			}
			else
			{
				if (end < count)
				{
					end = count;
				}
				count = 0;
			}
		}
			printf("%d", end);
			return 0;
}
2022/10/18 23:06
加载中...