fork download
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. void test(float a, float b, float c) {
  5. int n = round((c-a) / (b-a));
  6. for (int i=0; i<=n; i++) {
  7. printf("%g ", i*(b-a)+a);
  8. }
  9. printf("\n");
  10. }
  11.  
  12. void test_floor(float a, float b, float c) {
  13. int n = floor((c-a) / (b-a));
  14. for (int i=0; i<=n; i++) {
  15. printf("%g ", i*(b-a)+a);
  16. }
  17. printf("\n");
  18. }
  19.  
  20. int main() {
  21. test(1.3, 1.6, 2.8);
  22. test_floor(1.3, 1.6, 2.8);
  23. return 0;
  24. }
Success #stdin #stdout 0.01s 2680KB
stdin
Standard input is empty
stdout
1.3 1.6 1.9 2.2 2.5 2.8 
1.3 1.6 1.9 2.2 2.5