找不出错误,为什么只能执行两簇就执行不下去了
#include <iostream>#include <cstdio>
using namespace std;
int main()
{
int n, m;
while(scanf("%d %d", &n, &m) != EOF)
{
int temp = 0, s = 0, k = 0;
int arr[50] = {0}, brr[50] = {0};
for(int i = 2, j = 0; i<=2*n; i+=2, j++)
arr[j] = i;
for(int i = 0; arr[i]; i++)
{
s+=arr[i];
if((i+1)%m==0)
{
brr[k] = s;
k++;
s = 0;
}
if(arr[i+1]==0)
brr[k] = s;
}
for(int i = 0; i<=k; i++)
{
if(i == 0)
cout<<brr[i]/m;
else if(i == k)
cout<<" "<<brr[i]/(n%m);
else
cout<<" "<<brr[i]/m;
}
cout<<endl;
}
return 0;
}