fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4.  
  5.  
  6. int main(int argc, char *argv[]) {
  7. double a,b,i,j,dx;
  8. scanf("%lf%lf%lf%lf%lf",&a,&b,&i,&j,&dx);//輸入double型別請輸入lf
  9. double ans=0.0;
  10. // double range=j-i;
  11. // printf("%.2f",range);
  12. double le=(double) i;
  13.  
  14. // printf("%.2f",le);
  15.  
  16. while(le<j){
  17. if(le+dx>j){
  18. // printf("0");
  19. ans=ans+1000*((a*sin(le)+b*cos(le))*(j-le)) ;
  20. }
  21. else{
  22. // printf("1");
  23. ans= ans+1000*(a*sin(le)+b*cos(le))*(dx);
  24. }
  25. le+=dx;
  26. }
  27. ans=ans/1000;
  28. printf("%.2lf",ans);
  29. return 0;
  30. }
Success #stdin #stdout 0s 5308KB
stdin
10.0 3.0 0.0 9.999 0.01
stdout
16.82