Question: C++ looping and array In the source file, declare another array of circles with 6 elements. Using a looping statement to put the circles in
C++ looping and array
In the source file, declare another array of circles with 6 elements. Using a looping statement to put the circles in the array a into the newly declared array by following rules:
1. The first circle in the array a goes to the first element of the new array.
2. If a circle in array a is greater than all the circles in the new array, then put this circle after the last circle in the new array, otherwise, insert this circle right in front of the first circle in the new array that is greater than or equal to this circle.
#include #include"Circle.h" using namespace std;
int main() { Circle a[6]={Circle(5),Circle(7),Circle(2),Circle(3),Circle(11),Circle(6)}; Circle t; t=a[0]; for(int i=0;i<6;i++){ if(a[i]>t) t=a[i]; } cout<<"The largest circle is "< //system("pause"); <-- you may need to add this line if you are using VS C++ return 0; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
