fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int a,b;
  6. cin >> a >> b;
  7. int x = a%3;
  8. int y = 3-x;
  9. if(x == 0){
  10. for(int i = a;i <= b;i+=3){
  11. cout << i << " ";
  12. }
  13. }
  14. else {
  15. for(int i = a+y;i <= b;i+= 3 ){
  16. cout << i << " ";
  17. }
  18. }
  19. return 0;
  20. }
Success #stdin #stdout 0s 5324KB
stdin
2 10
stdout
3 6 9