In: Computer Science
All the explanation is in the comments of the code itself.
Code--
#include<bits/stdc++.h>
using namespace std;
class Circle
{
private:
int radius;
public:
double Get()
{
return radius;
}
void Put(int d)
{
radius=d;
}
};
void swap(Circle &x,Circle &y)
{
Circle temp;
temp.Put(x.Get());
x.Put(y.Get());
y.Put(temp.Get());
}
int main()
{
//declare an one dimentional array of Circle
Circle cirArr[10];
int t;
//prompt the user to give the inputs
cout<<"Input:"<<endl;
for(int i=0;i<10;i++)
{
cin>>t;
cirArr[i].Put(t);
}
//sort the array
for(int i=0;i<9;i++)
{
for(int j=0;j<10-i-1;j++)
{
if(cirArr[j].Get()>cirArr[j+1].Get())
{
swap(cirArr[j],cirArr[j+1]);
}
}
}
//display the array after sorting
cout<<"Output after sorting:"<<endl;
for(int i=0;i<10;i++)
{
cout<<cirArr[i].Get()<<" ";
}
}
Output Screenshot--
Note--
Please upvote if you like the effort.