解题思路:判断 i%3==1 && i%5==3
注意事项:sum+=i;记得sum的初值为0
参考代码:
/* */ #include <cstdio> #include <algorithm> #include <iostream> using namespace std; int main(){ int x,y; cin>>x>>y; int sum=0; for(int i=x;i<=y;i++){ if(i%3==1 && i%5==3) sum+=i; } cout<<sum; return 0; }
0.0分
0 人评分