From 5434ce319253a225108edac1991209a6f0afc94c Mon Sep 17 00:00:00 2001 From: flykhan Date: Sat, 24 Jun 2023 10:19:24 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BE=93=E5=87=BA=E4=B8=80=E4=B8=AA=E6=95=B0?= =?UTF-8?q?=E7=9A=84=E6=89=80=E6=9C=89=E5=9B=A0=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- day7/homework/oh1.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 day7/homework/oh1.cpp diff --git a/day7/homework/oh1.cpp b/day7/homework/oh1.cpp new file mode 100644 index 0000000..72584e4 --- /dev/null +++ b/day7/homework/oh1.cpp @@ -0,0 +1,22 @@ +// 输入一个整数,输出它的所有因数。 +// 例如:输入 12,输出 1 2 3 4 6 12 +#include + +using namespace std; + +int main() +{ + int n; + cout << "请输入一个整数:"; + cin >> n; + + int i = 1; + while (i <= n) + { + if (n % i == 0) + cout << i << "\t"; + i++; + } + + return 0; +} \ No newline at end of file