标签:else 循环 结果 OLE region 九九乘法表 for int write
#region
//右上
for (int i = 1; i <= 9; i++){
for (int j = 1; j <= 9; j++){
if (i > j){
Console.Write("\t");
} else{
Console.Write("{0}*{1}={2}\t", i, j, i * j);
}
}
Console.Write("\n");
}
Console.ReadKey();
//右下
for (int i = 1; i <= 9; i++){
for (int j = 1; j <= 9; j++){
if (i < 9 + 1 - j){
Console.Write("\t");
}else{
Console.Write("{0}*{1}={2}\t", i, j, i * j);
}
}
Console.Write("\n");
}
Console.ReadKey();
Console.Write("\n\n\n\n\n上层结束\n");
//左上
for (int i = 1; i <= 9; i++){
for (int j = i; j <= 9; j++)
{
if (i > j){
Console.Write("\t");
} else{
Console.Write("{0}*{1}={2}\t", i, j, i * j);
}
}
Console.Write("\n");
}
Console.ReadKey();
Console.Write("\n\n\n\n\n");
//左下
for (int i = 1; i <= 9; i++){
for (int j = 1; j <= 9; j++){
if (i <j){
Console.Write("\t");
}else{
Console.Write("{0}*{1}={2}\t", i, j, i * j);
}
}
Console.Write("\n");
}
Console.ReadKey();
Console.Write("\n\n\n\n\n");
//右上
for (int i = 1; i <= 9; i++){
for (int a = 1;a < i; a++){
Console.Write("\t");
}
for (int j = i; j <= 9; j++) {
Console.Write("{0}*{1}={2}\t", i, j, i * j);
}
Console.Write("\n");
}
Console.ReadKey();
Console.Write("\n\n\n\n\n");
#endregion
附加运行结果:
九九乘法表的四种三角形排布方式(for循环以及while循环的互换)
标签:else 循环 结果 OLE region 九九乘法表 for int write
原文地址:https://www.cnblogs.com/Kai-YoungMaster/p/12375174.html