0801out传值
//使用 out传值的时候仅仅是将变量名(箱子)拿过来
//并不会管之前是什么值
//函数体结束之前必须对该out的参数进行赋值,否则报错(不好意思还回去)
//out传值,可以进行多个值的传回
public void Jia(int b,out int c)
{
//c += 3;//c=c+3;
c = b + 10;
}
//使用return如何返回多个值
public string fanhui()
{
return 1 + "-" + 2 + "-" + 5;
}
public void yang()
{
Console.Write("请输入走过的村庄数:");
int n = int.Parse(Console.ReadLine());
int sum = 2;
for (int i = 0; i < n; i++)
{
sum = (sum + 1) * 2;
}
Console.Write("一共有" + sum + "只羊。");
}
static void Main(string[] args)
{
//求羊
//每过一个村庄,卖掉之前的总数的二分之一零1只
//过了七个村庄之后还有两只
//问最初赶了多少羊出来
Program yang1 = new Program();
yang1.yang();
Console.ReadLine();
//Program hanshu = new Program();
//string[] array = hanshu.fanhui().Split('-');
//int [] arr = new int[array.Length];
//for (int i = 0; i < array.Length; i++)
//{
// arr[i] = int.Parse( array[i]);
//}
//Console.Write("请输入a=");
//int a = int.Parse(Console.ReadLine());
//int c = 4;
//Program hanshu = new Program();
//hanshu.Jia(a,out c);
//Console.WriteLine(c);
//Console.ReadLine();