控制台输出九九乘法表和菱形
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication3
{
class Program
{
static void Main(string[] args)
{
//#region 乘法口诀
//for (int i = 1; i <= 9; i++)
//{
// for (int j = 1; j <= i; j++)
// {
// Console.Write("{0}*{1}={2}" + " ", i, j, i * j);
// }
// Console.WriteLine();
//}
//Console.Read();
//#endregion
#region 菱形打印
int i, j, k;
Console.WriteLine("请输入正三角形的行数");
int Q = Convert.ToInt32(Console.ReadLine());
for (i = 1; i <= Q; i++)
{
for (j = 1; j <= Q - i; j++)
{
Console.Write(" ");
}
for (k = 1; k <= 2 * i - 1; k++)
{
Console.Write("*");
}
Console.WriteLine();
}
for (i = 1; i <= Q - 1; i++)
{
for (j = 1; j <= i; j++)
{
Console.Write(" ");
}
for (k = 1; k <= 2 * Q - 2 * i - 1; k++)
{
Console.Write("*");
}
Console.WriteLine();
}
Console.Read();
#endregion
}
}
}