fork download
  1. #include <iostream>
  2. #include <iomanip> // for std::setprecision
  3.  
  4. int main() {
  5. // 반지름을 저장할 변수
  6. double radius;
  7. // 원주율
  8. const double pi = 3.14;
  9.  
  10. // 사용자로부터 반지름 입력받기
  11. std::cout << "원의 반지름을 입력하세요: ";
  12. std::cin >> radius;
  13.  
  14. // 원의 넓이 계산
  15. double area = pi * radius * radius;
  16.  
  17. // 결과를 소수점 이하 둘째 자리에서 반올림하여 첫째 자리까지 출력
  18. std::cout << "원의 넓이는: " << std::fixed << std::setprecision(1) << area << std::endl;
  19.  
  20. return 0;
  21. }
  22.  
Success #stdin #stdout 0.01s 5272KB
stdin
Standard input is empty
stdout
원의 반지름을 입력하세요: 원의 넓이는: 0.0