这是我的代码,用于查找数字的倍数。但它不输出倍数。
#include <iostream>
using namespace std;
int main()
{
cout << "Enter the number:" << endl;
int num;
cin >> num;
for (int i = 1; i == num; i++) {
if ((num % i) == 0) {
int res = num / i;
cout << num << " divided by " << i << "=" << res << endl;
}
}
return 0;
}
答案 0 :(得分:4)
问题是由于for循环中的条件:
for (int i = 1; i == num; i++) {
待办事项
for (int i = 1; i <= num; i++) {