fork download
  1. #include <iostream>
  2. #include <math.h>
  3. #include <stdlib.h>
  4. int main() {
  5. double rule_spacing = 0.05;
  6. // These are the highlighted rules - currently it should be every 2nd rule
  7. double important_steps = rule_spacing*2.0;
  8. // Getting the stard draw offset which should be bellow bottom graph corner
  9. double start = 105.6;
  10. double maxYValue = 106.149;
  11. std::cout<<"Legend from "<<start<<" to "<<maxYValue<<" by "<<rule_spacing<<", important_steps: "<<important_steps<<'\n';
  12. //Loop until on top
  13. while(start <= maxYValue) {
  14. //double remainder = fmod(start, important_steps);
  15. float quotient = start / important_steps;
  16. int quot_int = round(quotient);
  17. std::cout<<" "<<" legend with marker "<<start<<" Marker remainder:"<<abs(quotient - quot_int)<<'\n';
  18. //if(remainder==0 || remainder==important_steps || remainder<important_steps/1000.0) {
  19. if (abs(quotient - quot_int) < 1e-10) {
  20. std::cout<<" BIG RULE!"<<'\n';
  21. }
  22. else
  23. std::cout<<" small rule."<<'\n';
  24. start+=rule_spacing;
  25. }
  26. }
Success #stdin #stdout 0s 3412KB
stdin
Standard input is empty
stdout
Legend from 105.6 to 106.149 by 0.05, important_steps: 0.1
         legend with marker 105.6 Marker remainder:0
          BIG RULE!
         legend with marker 105.65 Marker remainder:0
          BIG RULE!
         legend with marker 105.7 Marker remainder:0
          BIG RULE!
         legend with marker 105.75 Marker remainder:0
          BIG RULE!
         legend with marker 105.8 Marker remainder:0
          BIG RULE!
         legend with marker 105.85 Marker remainder:0
          BIG RULE!
         legend with marker 105.9 Marker remainder:0
          BIG RULE!
         legend with marker 105.95 Marker remainder:0
          BIG RULE!
         legend with marker 106 Marker remainder:0
          BIG RULE!
         legend with marker 106.05 Marker remainder:0
          BIG RULE!
         legend with marker 106.1 Marker remainder:0
          BIG RULE!