本帖最后由 bin554385863 于 2019-10-22 23:27 编辑 #include <iostream>
int main(int argc, char const *argv[])
{
for (size_t i = 1; i < 10; i++)//控制行
{
for (size_t j = 1; j <= i; j++)//控制列
{
printf("%dX%d=%2d ", j, i, i * j);
}
printf("\n");//内层每完成i次循环,外层打印一次换行
}
return 0;
}
---------------------------------------------------------------------------------------------------------------
Microsoft Windows [版本 10.0.16299.1087]
(c) 2017 Microsoft Corporation。保留所有权利。
E:\Users\86184\Documents\Code>c:\Users\86184\.vscode\extensions\ms-vscode.cpptools-0.26.0\debugAdapters\bin\WindowsDebugLauncher.exe --stdin=Microsoft-MIEngine-In-5kosn4ur.fx4 --stdout=Microsoft-MIEngine-Out-umo3qoeh.knl --stderr=Microsoft-MIEngine-Error-kyifrxzn.yov --pid=Microsoft-MIEngine-Pid-dw0aq1lg.2ni "--dbgExe=E:\My Program\MinGW\bin\gdb.exe" --interpreter=mi
1X1= 1
1X2= 2 2X2= 4
1X3= 3 2X3= 6 3X3= 9
1X4= 4 2X4= 8 3X4=12 4X4=16
1X5= 5 2X5=10 3X5=15 4X5=20 5X5=25
1X6= 6 2X6=12 3X6=18 4X6=24 5X6=30 6X6=36
1X7= 7 2X7=14 3X7=21 4X7=28 5X7=35 6X7=42 7X7=49
1X8= 8 2X8=16 3X8=24 4X8=32 5X8=40 6X8=48 7X8=56 8X8=64
1X9= 9 2X9=18 3X9=27 4X9=36 5X9=45 6X9=54 7X9=63 8X9=72 9X9=81
E:\Users\86184\Documents\Code>
=======================================================
倒序#include <iostream>
int main(int argc, char const *argv[])
{
for (size_t i = 9; i >= 1; i--) //控制行
{
for (size_t j = 1; j <= i; j++) //控制列
{
printf("%dX%d=%2d ", j, i, i * j);
}
printf("\n"); //内层每完成i次循环,外层打印一次换行
}
return 0;
}
-----------------------------------------------------------------------------------------------------------------------------
Microsoft Windows [版本 10.0.16299.1087]
(c) 2017 Microsoft Corporation。保留所有权利。
E:\Users\86184\Documents\Code>c:\Users\86184\.vscode\extensions\ms-vscode.cpptools-0.26.0\debugAdapters\bin\WindowsDebugLauncher.exe --stdin=Microsoft-MIEngine-In-s1vqqpin.jpr --stdout=Microsoft-MIEngine-Out-qusqcgs1.ind --stderr=Microsoft-MIEngine-Error-awammhke.fmu --pid=Microsoft-MIEngine-Pid-lyi5ydnv.4hm "--dbgExe=E:\My Program\MinGW\bin\gdb.exe" --interpreter=mi
1X9= 9 2X9=18 3X9=27 4X9=36 5X9=45 6X9=54 7X9=63 8X9=72 9X9=81
1X8= 8 2X8=16 3X8=24 4X8=32 5X8=40 6X8=48 7X8=56 8X8=64
1X7= 7 2X7=14 3X7=21 4X7=28 5X7=35 6X7=42 7X7=49
1X6= 6 2X6=12 3X6=18 4X6=24 5X6=30 6X6=36
1X5= 5 2X5=10 3X5=15 4X5=20 5X5=25
1X4= 4 2X4= 8 3X4=12 4X4=16
1X3= 3 2X3= 6 3X3= 9
1X2= 2 2X2= 4
1X1= 1
E:\Users\86184\Documents\Code> |