20分求助QwQ
查看原帖
20分求助QwQ
752252
fish_hate_cat楼主2022/11/4 12:54

c++

#include<iostream>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	int c[105];
	for(int i=0;i<a;i++)
	{
		cin>>c[i];
	}
	int small=1000;
	int temp=0;
	for(int i=0;i<=a-b+1;i++)
	{
		for(int k=0;k<b;k++)
		{
			temp+=c[i+k];
		}
		if(small>temp)
		{
			small=temp;
		}
	}
	cout<<small;
	return 0;
}
2022/11/4 12:54
加载中...