#region
//右上
for (int i = 1; i <= 9; i++){
for (int j = 1; j <= 9; j++){
if (i > j){
Console.Write(" ");
} else{
Console.Write("{0}*{1}={2} ", i, j, i * j);
}
}
Console.Write("
");
}
Console.ReadKey();
//右下
for (int i = 1; i <= 9; i++){
for (int j = 1; j <= 9; j++){
if (i < 9 + 1 - j){
Console.Write(" ");
}else{
Console.Write("{0}*{1}={2} ", i, j, i * j);
}
}
Console.Write("
");
}
Console.ReadKey();
Console.Write("
上层结束
");
//左上
for (int i = 1; i <= 9; i++){
for (int j = i; j <= 9; j++)
{
if (i > j){
Console.Write(" ");
} else{
Console.Write("{0}*{1}={2} ", i, j, i * j);
}
}
Console.Write("
");
}
Console.ReadKey();
Console.Write("
");
//左下
for (int i = 1; i <= 9; i++){
for (int j = 1; j <= 9; j++){
if (i <j){
Console.Write(" ");
}else{
Console.Write("{0}*{1}={2} ", i, j, i * j);
}
}
Console.Write("
");
}
Console.ReadKey();
Console.Write("
");
//右上
for (int i = 1; i <= 9; i++){
for (int a = 1;a < i; a++){
Console.Write(" ");
}
for (int j = i; j <= 9; j++) {
Console.Write("{0}*{1}={2} ", i, j, i * j);
}
Console.Write("
");
}
Console.ReadKey();
Console.Write("
");
#endregion
附加运行结果: