Advertisement
Guest User

Untitled

a guest
Dec 6th, 2016
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include "Circle.h" // Circle class declaration file
  4. using namespace std;
  5.  
  6. void sortArray(int [], int);
  7. void showArray(const int [], int);
  8. int main()
  9. {
  10. const int NUM_CIRCLES = 7;
  11.  
  12. Circle circle[NUM_CIRCLES] = {2.5, 4.0, 1.0, 3.0, 6.0, 5.5, 2.0 }; // Define an array of Circle objects
  13.  
  14. // Use a loop to initialize the radius of each object
  15. for (int index = 0; index < NUM_CIRCLES; index++)
  16. { double r;
  17. cout << "The radius for circle " << (index+1) << ": "<<endl;
  18. showArray(circle, NUM_CIRCLES);
  19. circle[index].setRadius(r);
  20. }
  21.  
  22. // Use a loop to get and print out the area of each object
  23. cout << fixed << showpoint << setprecision(2);
  24. cout << "\nHere are the areas of the " << NUM_CIRCLES
  25. << " circles.\n";
  26. for (int index = 0; index < NUM_CIRCLES; index++)
  27. { cout << "circle " << (index+1) << setw(8)
  28. << circle[index].findArea() << endl;
  29. }
  30. return 0;
  31. }
  32. void sortArray(int array[],int size)
  33. {
  34. int temp;
  35. bool madeAswap;
  36.  
  37. do
  38. {
  39. madeAswap = false;
  40. for (int count = 0; count < (size - 1); count++)
  41. {
  42. if (array[count] > array[count + 1])
  43. {
  44. temp = array[count];
  45. array[count] = array[count + 1];
  46. array[count + 1] = temp;
  47. madeAswap = true;
  48. }
  49. }
  50. } while (madeAswap);
  51. }
  52. void showArray(const int array[], int size)
  53. {
  54. for (int count = 0; count < size; count++)
  55. cout<<array[count]<<" ";
  56. cout<<endl;
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement