1块钱买一瓶汽水,两个空瓶能换一瓶汽水,问20块钱最多能喝多少瓶汽水?
using
System;
class Method
... {
static void Main()
...{
int a = 20;//钱
int b = 0;//汽水
int c = 0;//空瓶
while (a > 0)
...{
b++;
c++;
if (c > 1)//二个瓶时换一瓶汽水
...{
c -=2;
b ++;
c ++;
}
a --;
}
Console.WriteLine("喝了" + b.ToString() + "汽水");
}
}
class Method
... {
static void Main()
...{
int a = 20;//钱
int b = 0;//汽水
int c = 0;//空瓶
while (a > 0)
...{
b++;
c++;
if (c > 1)//二个瓶时换一瓶汽水
...{
c -=2;
b ++;
c ++;
}
a --;
}
Console.WriteLine("喝了" + b.ToString() + "汽水");
}
}