qfedu-basic-level/day7/homework/oh1.cpp

22 lines
348 B
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 输入一个整数,输出它的所有因数。
// 例如:输入 12输出 1 2 3 4 6 12
#include <iostream>
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;
}