在1——500中,找出能同时满足用3除余2,用5除余3,用7除余2的所有整数;
在做一个吧#include <iostream>
#include <list>
using namespace std;
int main()
{
list <int> answer;
int i;
for(i=1;i<=500;i++)
{
if((i%3==2)&&(i%5==3)&&(i%7==2))
{
answer.push_back(i);
}
}
list <int> ::iterator p=answer.begin();
while(p!=answer.end())
{
cout<<*p<<" ";
p++;
}
return 0;
} 好玩:@D
#!/usr/bin/env python
def mod(x,y,z):
return divmod(x,y) == z
页:
[1]