日期:2014-05-17 浏览次数:20434 次
int count = 10;
int empty = 0;
while (count > 0)
{
Console.WriteLine("喝一瓶饮料");
empty++;
count--;
if (empty == 3)
{
Console.WriteLine("3个空瓶子兑换一瓶饮料");
count += 1;
empty = 0;
}
Console.WriteLine("剩余饮料数:{0},剩余空瓶子:{1}", count, empty);
}
Console.Read();
int count = 10;
int flag = 3;
int empty = count / flag + count % flag;
while (empty >= flag)
{
empty = empty / flag + empty % flag;
}
Console.WriteLine("剩余饮料数:0,剩余空瓶子:{0}", empty);
Console.Read();
public int[] DrinkWater(int total)
{
&nbs