#include <iostream>
using namespace std;
int f(int a[])
{
int i,f=0;
for(i=0;i<=9;i++){
if(a[0]!=a[i])
f=1;
}return f;
}
int main()
{
int a[10]={10,2,8,22,16,4,10,6,14,20};
int t[10];
int count=0;
while(f(a))
{
for(int i=0;i<=9;i++){
if(a[i]%2==0)
t[i]=a[i]=a[i]/2;
else t[i]=a[i]=(a[i]+1)/2;}
for(int j=1;j<10;j++){
a[j]=t[j-1]+a[j];
a[0]=t[9]+a[0];}
count++;
}
cout<<"个数"<<a[4]<<" 次数="<<count;
return 0;
}
标签:std,10,return,int,count,糖果 From: https://www.cnblogs.com/jmhyyds/p/17324011.html