【华为OJ】【021-汽水瓶】
题目链接:
https://blog.csdn.net/DERRANTCM/article/details/51335956
C++实现:
int GetSum(int nBt)
{
int n1,n2;
n1 = nBt / 3;
n2 = nBt % 3;
if (nBt >= 3)
return n1+GetSum(n1+n2);
else if(nBt == 2)
return 1;
else
return 0;
}
void main()
{
vector<int> nList;
int iIn;
do
{
cin >> iIn;
nList.push_back(iIn);
} while (iIn != 0);
nList.pop_back();
for (int i=0; i<nList.size();i++)
{
cout << GetSum(nList[i]) << endl;
}
system("pause");
}