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