Guest User

Untitled

a guest
May 26th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. #define PI 3.14159265358979323846
  5.  
  6. int main(void){
  7.  
  8. double a,r,theta;
  9. printf("R = ?");
  10. scanf("%lf", &r);
  11. printf("θ = ?");
  12. scanf("%lf", &theta);
  13.  
  14. a = 2 * r * sin(PI * theta / 180);
  15. /*
  16. sin,cos,tanの()の中身はラジアンとみなされるので適切に変換する必要がある
  17. ちなみにmath.hをincludeするとM_PIで円周率がすでに定義されてるよ
  18. */
  19.  
  20. printf("a = %6.2f\n", a);
  21.  
  22. return 0;
  23. }
  24.  
  25. /*
  26. math.hをincludeしたプログラムをコンパイルする際は引数に -lm を与えること
  27. 例)cc sample.c -lm
  28. */
Add Comment
Please, Sign In to add comment