/// <summary>
/// 1、篮球从20米高度落地,弹起高度是上次的3/4,
/// 输入次数算出高度(有参数,有返回值)
/// </summary>
/// <param name="times"></param>
/// <returns></returns>
public double basketball (int times)
{
double height=20.0;
for (int i = 1; i <= times;i++ )
{
height *= (double)3/4;
Console.WriteLine("篮球弹起第"+i+"次的高度为:"+height+"米");
}
return height;
}
static void Main(string[] args)
{
Program hanshu = new Program();
Console.Write("请输入弹起次数:");
int times = int.Parse(Console.ReadLine());
hanshu.basketball(times);
Console.ReadLine();
}
/// <summary>
/// 2、打印等腰三角形
/// </summary>
public void sanjiaoxing()
{
Console.Write("请输入行数:");
int hang = int.Parse(Console.ReadLine());
for (int i = 1; i <= hang;i++ )//控制行
{
for (int j = hang-1; j >=i;j-- ) //左边空格三角形
{
Console.Write(" ");
}
for (int x = 1; x <= 2 * i - 1;x++ )//右边等腰三角形
{
Console.Write("@");
}
Console.WriteLine();
}
}
static void Main(string[] args)
{
Program hanshu = new Program();
hanshu.sanjiaoxing();
Console.ReadLine();
}