求大佬帮忙,输入n后,运行系统输入无休止
查看原帖
求大佬帮忙,输入n后,运行系统输入无休止
916027
qew12312楼主2023/1/5 17:08
#include<iostream>
#include<cmath>
using namespace std;
int main(){
	int n,m;
	cin>>n>>m;
	double a[n][0],sum=0,sum1=0;
	for(int y=0;y<n;y++){
		cin>>a[y][0];
	}
	for(int u=0;u==0;u++){
		for(int y=0;y<m;y++){
			sum+=a[u+y][0];
		}
	}
for(int u=m;u<=n-m;u++){
		for(int y=0;y<m;y++){
			sum1+=a[u+y][0];
		}
		sum=min(sum1,sum);
	}
cout<<sum1;
	return 0;
}
	
	
	
	
2023/1/5 17:08
加载中...