圣诞树
昨晚闲无事,写的一个圣诞树!呵呵!很简单!记个笔记吧!
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication3
{
class Program
{
static void Main(string[] args)
{
string strLevel = Console.ReadLine();
Program ss = new Program();
ss.PrintHappy(int.Parse(strLevel));
Console.ReadKey();
}
private String PrintS(string C,int intCount)
{
return intCount<=0?"":PrintS(C,intCount-1)+C;
}
private void PrintLineString(int intC1,int intC2)
{
Console.WriteLine(PrintS(" ", intC1).ToString() + PrintS("*", intC2).ToString());
}
private void PrintHappy(int intLevel)
{
for (int i = intLevel,j=1; 0 <i ; i--,j+=2)
{
PrintLineString(i, j);
}
PrintLineString(intLevel-1, 1);
}
}
}
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication3
{
class Program
{
static void Main(string[] args)
{
string strLevel = Console.ReadLine();
Program ss = new Program();
ss.PrintHappy(int.Parse(strLevel));
Console.ReadKey();
}
private String PrintS(string C,int intCount)
{
return intCount<=0?"":PrintS(C,intCount-1)+C;
}
private void PrintLineString(int intC1,int intC2)
{
Console.WriteLine(PrintS(" ", intC1).ToString() + PrintS("*", intC2).ToString());
}
private void PrintHappy(int intLevel)
{
for (int i = intLevel,j=1; 0 <i ; i--,j+=2)
{
PrintLineString(i, j);
}
PrintLineString(intLevel-1, 1);
}
}
}