一道小學(xué)題,讓數(shù)學(xué)大神三天三夜沒(méi)睡著覺(jué)

class Peach{
public:??
int count = 0;??
int total = 0;??
int nucleus = 0;??
int money = 100;??
void BuyPeach(){????
money--;????count++;??
}??
void Eat(){????
count--;????nucleus++;????total++;?
?}??
void Exchange(){????
count += nucleus/2;????
nucleus -= nucleus/2*2;??
}??
void PrintArrtibute(){????
cout << "total is " << total << endl;????
cout << "money is " << money << endl;????
cout << "nucleus is " << nucleus << endl;????
cout << "count is " << count << endl;??
}
};
void TotalPeach(){??
Peach P;??
while(P.money>0){???
?P.BuyPeach();??
}??
while(P.count>0{????
P.Eat();????
if(P.nucleus>=2)P.Exchange();??
}??
P.PrintArrtibute();}
int main() {??
TotalPeach();??
return 0;
}
標(biāo)簽: