编写代码如下:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _1
{
class Program
{
static void Main(string[] args)
{
int k1 = 364;
int k2 = 364;
while (k1>=3)
{
k2+= k1 / 3;
k1 = (k1 / 3) + (k1 % 3);
}
Console.WriteLine("一共可以喝{0}瓶可乐,剩下{1}个空瓶", k2, k1);
Console.ReadKey(true);
}
}
}
程序运行结果如下:
编写代码如下:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("请输入字符串:");
string str = Console.ReadLine();
//把字符串转化为字符数组
char[] strArray = str.ToA