#include <iostream>
#include <fstream>
using namespace std;
class Shape
{
  public:
    string name;
    double width, height, radius;
  public:
    void set_data (double a, double b)
    {
        width = a;
        height = b;
    }
    virtual double area() = 0;
};
class Rectangle: public Shape
{
public:
    double area ()
    {
        return (width * height);
    }
};
class Triangle: public Shape
{
public:
    double area ()
    {
        return (width * height)/2;
    }
};
class Circle : public Shape
{
  public:
    double area ()
    {
        return 3.1415 * (radius * radius);
    }
};
int main()
{
    int N;
    cin >> N;
    Rectangle Rect;
    Triangle Tri;
    Circle Circ;
    string* S = new string[N];
    if(N == 1) {
      cin >> Rect.name >> Rect.height >> Rect.width;
      cout << Rect.area();
      return 0;
    } 
    else
{
    for(int i = 0; i < N; i++)
    {
        cin >> S[i];
        if(S[i] == "Rectangle")
        {
            cin >> Rect.height;
            cin >> Rect.width;
        }
         else if(S[i] == "Triangle")
             {
                 cin >> Tri.height;
                 cin >> Tri.width;
             }
             else if(S[i] == "Circle")
                  {
                      cin >> Circ.radius;
                  } 
    }
}
    cout << Rect.area() << " " << Tri.area() << " " << Circ.area();
  delete [] S;
    return 0;
}
the code works well in the Test 1 and Test 2, but in Test 3 give an error... im need to input N number(count of Shapes) and display in Output all areas in ascending order...
For Example:
====== TEST #1 =======
Input:
1
Rectangle 4 3
Output: 12
The True Answer: 12
OK!
====== TEST #2 =======
Input:
3
Triangle 4 6
Rectangle 2 3
Circle 3
Output: 6 12 28.2735
The True Answer: 6 12 28.2735
OK!
====== TEST #3 =======
Input:
5
Triangle 4 6
Rectangle 2 3
Circle 4
Triangle 7 11
Triangle 3 5
Output: 6 7.5 50.264
The True Answer: 6 7.5 12 38.5 50.264
Error!
Please tell me, why my code is not working?
 
    