/*设计函数int factors(int num,int k),返回整数num中包含因子k的个数,如果没有该因子,则返回0
例如:factors(8,2)=3*/
#include<iostream>
using namespace std;
int factor(int num, int k)
{
for (int i = 1;num>=(k^i); i++)
{
if (num == (k ^ i))
{
break;
return i;
}
else if (num != (k ^ i))return 0;
}
}
int main3()
{
int a, b;
cout << "please enter an intiger" << endl;
cin >> a;
cout << "请输入一个因子" << endl;
cin >> b;
int c = factor(a, b);
cout << "包含该因子的个数为" << c << endl;
system("pause");
return 0;
}
![](https://profile-avatar.csdnimg.cn/1ff2387132ee4369bbafc99d4f0ea6d6_m0_74440311.jpg!4)
请帮我找一下我哪里错了。 设计函数int factors(int num,int k),返回整数num中包含因子k的个数,如果没有该因子,则返回0
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
1条回答 默认 最新
悬赏问题
- ¥15 matlab数据降噪处理,提高数据的可信度,确保峰值信号的不损失?
- ¥15 怎么看我在bios每次修改的日志
- ¥15 python+mysql图书管理系统
- ¥15 Questasim Error: (vcom-13)
- ¥15 船舶旋回实验matlab
- ¥30 SQL 数组,游标,递归覆盖原值
- ¥15 为什么我的数据接收的那么慢呀有没有完整的 hal 库并 代码呀有的话能不能发我一份并且我用 printf 函数显示处理之后的数据,用 debug 就不能运行了呢
- ¥20 gitlab 中文路径,无法下载
- ¥15 用动态规划算法均分纸牌
- ¥30 udp socket,bind 0.0.0.0 ,如何自动选取用户访问的服务器IP来回复数据