|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
- #include<iostream>
- #include<cmath>
- using namespace std;
- int main()
- {
- int m, n;
- int gs = 0;
- int z = 0;
- cin >> m >> n;//m<n
- for (int i = m; i <= n; i++)
- {
- gs = 0;
- for (int r = 1; r <= i; r++)
- {
- if ((i & r) == 0)
- {
- gs++;
- }
- }
- if (gs == 2)
- {
- z += i;
- }
- }cout << z << endl;
- system("pause");
- return 0;
- }
复制代码
你的 % 打成了 &,应该是: - #include<iostream>
- #include<cmath>
- using namespace std;
- int main()
- {
- int m, n;
- int gs = 0;
- int z = 0;
- cin >> m >> n;//m<n
- for (int i = m; i <= n; i++)
- {
- gs = 0;
- for (int r = 1; r <= i; r++)
- {
- if ((i % r) == 0)
- {
- gs++;
- }
- }
- if (gs == 2)
- {
- z += i;
- }
- }cout << z << endl;
- system("pause");
- return 0;
- }
复制代码
|
|