Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- template <typename T>
- T* my_realloc(T* src, size_t old_size, size_t new_size){
- T* new_src = new T[new_size];
- for (int i = 0; i < old_size; i++)
- new_src[i] = src[i];
- delete [] src;
- src = new_src;
- return src;
- }
- // class Cat{
- // public:
- // Cat(string _name, int _age) : name(_name), age(_age){}
- // Cat() : name(""), age(0){}
- // string name;
- // int age;
- // };
- // template<typename Type>
- // class Array{
- // Type *data;
- // int size;
- // int count;
- // public:
- // Array(){
- // size = 10;
- // count = 0;
- // data = new Type[size];
- // }
- // void push_back(Type& item){
- // if (count == size){
- // size += 10;
- // data = my_realloc<Type>(data, count, size);
- // }
- // data[count] = item;
- // ++count;
- // }
- // void pop_back(){
- // --count;
- // }
- // Type get(size_t index){
- // return data[index];
- // }
- // int index(Type item){
- // int ret = -1;
- // for (int i = 0; i < count; i++)
- // if (data[i] == item)
- // ret = i;
- // return ret;
- // }
- // };
- template<class TYPE>
- TYPE round(TYPE t,int prec)
- {
- for(int i=0;i<prec;i++)
- t*=10;
- int n=(int)t;
- if(t-n>=0.5)
- n++;
- t=n;
- for(int i=0;i<prec;i++)
- t/=10;
- return t;
- }
- struct Point{
- int x, y;
- };
- class Circle{
- Point centre;
- double radius;
- public:
- Circle(int x, int y, double rad){
- centre.x = x;
- centre.y = y;
- radius = rad;
- }
- Circle(){
- centre.x = 0;
- centre.y = 0;
- radius = 10;
- }
- double calcDistance(Circle& cir){
- int dx = abs(centre.x - cir.centre.x);
- int dy = abs(centre.y - cir.centre.y);
- double dist = std::sqrt(dx * dx + dy * dy);
- return round(dist, 1);
- }
- };
- class Sector : public Circle
- {
- int angle;
- public:
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement