C # implement a taosongye,
Some time ago, Insus. NET implemented a set of strings which were aligned to the left or right when output. The output character is right aligned http://www.cnblogs.com/insus/p/7953304.html
Now, for Insus. NET, refer to this method to implement a tarson leaf. before implementation, first practice and output half of the results:
Public void WriteTriangle () {char symbol = '*'; int star = 13; for (var I = 1; I <= star; I ++) {string s = new string (symbol, I); s = s. padLeft (star, ''); Console. writeLine (s) ;}} Source Code
Run the code to see what it looks like to lose?
The goal is 50%. Next, complete the other side and create another method for Insus. NET:
Public void WritePineTree () {char symbol = '*'; int star = 13; Console. writeLine (symbol. toString (). padLeft (star + 1, ''); for (var I = 1; I <= star; I ++) {string s = new string (symbol, I ); string left = s. padLeft (star, ''); string right = s. padRight (star, ''); Console. writeLine (left + symbol. toString () + right) ;}} Source Code
On the console, run the following code: