fork download
  1. #include <math.h>
  2. #include <stdio.h>
  3.  
  4. double enshu(double r)
  5. {
  6. return 2 * M_PI * r;
  7. }
  8.  
  9. double menseki(double &r)
  10. {
  11. return M_PI * r * r;
  12. }
  13.  
  14. int main()
  15. {
  16. double r, ring, area;
  17.  
  18. printf("半径rを入力:\n");
  19. scanf("%lf", &r);
  20. ring = enshu(r);
  21. area = menseki(r);
  22. printf("円周:%f\n", ring);
  23. printf("面積:%f\n", area);
  24. return 0;
  25. }
  26.  
Success #stdin #stdout 0.01s 2684KB
stdin
5
stdout
半径rを入力:
円周:31.415927
面積:78.539816