Advertisement
Infernale

NCTU LAB 02/04 NUM 3

Apr 2nd, 2019
481
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.55 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. using namespace std;
  4.  
  5. #define PI 3.1415926
  6. #define pTwo(x) x*x
  7.  
  8. struct Circle{
  9.     double radius;
  10. };
  11.  
  12. struct Ring{
  13.     Circle c1, c2;
  14. }ring;
  15.  
  16. double area(Ring ring){
  17.     return PI*pTwo(ring.c2.radius) - PI*pTwo(ring.c1.radius);
  18. }
  19.  
  20. int main(){
  21.     double startX, startY, smallRadius, largeRadius;
  22.     while(cin >> startX >> startY >> largeRadius >> smallRadius){
  23.         ring.c1.radius = smallRadius;
  24.         ring.c2.radius = largeRadius;
  25.         cout << fixed << setprecision(6) << "Area: " << area(ring) << endl;
  26.     }
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement