fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int foo(double a, double b)
  5. {
  6. int counter = 0;
  7. double h = (b - a) / 30;
  8. for (double x = a; x < b; x += h)
  9. ++counter;
  10. return counter;
  11. }
  12.  
  13. int main()
  14. {
  15. cout << foo(0.0, 1.0) << endl;
  16. cout << foo(1.0, 2.0) << endl;
  17. }
Success #stdin #stdout 0s 4880KB
stdin
Standard input is empty
stdout
31
30