分糖果
1 #include <iostream> 2 using namespace std; 3 int main() 4 { 5 int i,count=0; 6 int a[10]={10,2,8,22,16,4,10,6,14,20}; 7 int b[10]={10,2,8,22,16,4,10,6,14,20}; 8 do{ 9 a[0]=b[0]/2+b[9]/2; 10 for(int j=1;j<=9;j++) 11 { 12 a[j]=b[j]/2+b[j-1]/2; 13 } 14 for(int m=0;m<10;m++) 15 { 16 if(a[m]%2!=0) 17 { 18 a[m]+=1; 19 } 20 } 21 for(int i=0;i<10;i++) 22 { 23 b[i]=a[i]; 24 } 25 count++; 26 }while((a[0]!=a[1])||(a[1]!=a[2])||(a[2]!=a[3])||(a[3]!=a[4])||(a[4]!=a[5])||(a[5]!=a[6])||(a[6]!=a[7])||(a[7]!=a[8])||(a[8]!=a[9])); 27 cout<<count<<endl; 28 cout<<a[0]<<" "<<a[1]<<" "<<a[2]<<" "<<a[3]<<endl; 29 }
标签:10,20,14,22,int,编程,C++,趣味 From: https://www.cnblogs.com/Lyh3012648079/p/17413313.html