Форум программистов
 

Восстановите пароль или Зарегистрируйтесь на форуме, о проблемах и с заказом рекламы пишите сюда - alarforum@yandex.ru, проверяйте папку спам!

Вернуться   Форум программистов > IT форум > Помощь студентам
Регистрация

Восстановить пароль

Купить рекламу на форуме - 42 тыс руб за месяц

Ответ
 
Опции темы Поиск в этой теме
Старый 16.06.2013, 16:11   #1
xWoWx
Пользователь
 
Регистрация: 03.04.2012
Сообщений: 34
По умолчанию Написание программы на си++

Необходимо сделать следующие. В приведенным программном коду добавить программный код конуса. А так же написать программный код для конуса вписанного в целиндр. Ну и отдельно написать программный код для--- класс "квадратная матрица". методы: сложение с матрицей,транспонирование, вывод элементов на дисплей;
Код:
#include <iostream.h>
#include <conio.h>
#include <stdio.h>
#include <stdlib.h>
#include <dos.h>
#include <graphics.h>
#include <math.h>
#include <string.h>
class Figure
{
protected:
  int Color;
  int CenterX;
  int CenterY;
public:
  Figure(int iCenterX, int iCenterY)
  {
    Color = RED;
    CenterX = iCenterX;
    CenterY = iCenterY;
  }
  void SetNewColor(int NewColor)
  {
    Hide();  
    Color=NewColor;*
    Show();
  }
    virtual void Show() = 0;
    virtual void Hide()
  {
    int prev_col = Color;
    Color = getbkcolor();**
    Show();              
    Color = prev_col;
  }
   void Move(int DeltaX, int DeltaY)
  {
    Hide();
    CenterX+=DeltaX;
    CenterY+=DeltaY;
    Show();
  }
   virtual ~Figure()
  {};
};
class Circle: public Figure
{
private:
  int Radius;
public:
  Circle(int iCenterX, int iCenterY, int iRadius) :
    Figure(iCenterX, iCenterY)
  {
     Radius = iRadius;
  }
  void Show();
};
class Rectangle: public Figure
{
private:
  int h; *
  int w; **
public:
  Rectangle(int iCenterX, int iCenterY, int ih, int iw) :
    Figure(iCenterX, iCenterY)
  {
     h = ih;
     w = iw;
  }
  void Show();
};
class Message: public Figure
{
private:
  char* String;
public:
  Message(int iCenterX, int iCenterY, char* Msg) :
    Figure(iCenterX, iCenterY)
  {
     String = new char [strlen(Msg)+1];
     strcpy(String, Msg);
  }
  void Show();
  ~Message()
  {
     delete String;
  }
};
class Silinder: public Figure
{
private:
  int Radius;
public:
  Silinder( int iCenterX, 
	 int iCenterY, 
	 int iRadius ): 
    Figure(iCenterX, iCenterY)
  {
     Radius = iRadius;
  }
   void Show();
};

 KonsPriyam
class KonsPriyam: public Figure
{
private:
  int Size;
public:
  KonsPriyam( int iCenterX, 
	 int iCenterY, 
	 int iSize ):  
    Figure(iCenterX, iCenterY)
  {
     Size = iSize;
  }
    void Show();
};
void Silinder::Show()
{
  int prev_color=getcolor();
  setcolor(Color);
  line(CenterX - Radius / 2, CenterY - Radius / 2, CenterX - Radius / 2, CenterY + Radius / 2);
  line(CenterX + Radius / 2, CenterY - Radius / 2, CenterX + Radius / 2, CenterY + Radius / 2);
  ellipse(CenterX, CenterY + Radius / 2, 0,360, Radius / 2, Radius / 3);
  ellipse(CenterX, CenterY - Radius / 2, 0,360, Radius / 2, Radius / 3);
  setcolor(prev_color);
}
void Circle::Show()
{
  int prev_color=getcolor();
  setcolor(Color);
  circle(CenterX, CenterY, Radius);
  setcolor(prev_color);
}

// METODI KonsPriyam
void KonsPriyam::Show()
{
  int prev_color=getcolor();
  setcolor(Color);
  rectangle( CenterX - Size / 2, CenterY - Size / 2,
	     CenterX + Size / 2, CenterY + Size / 2);
  rectangle( CenterX - Size / 3, CenterY - Size / 3,
	     CenterX + Size / 3, CenterY + Size / 3);
 setcolor(prev_color);
}
void Rectangle::Show()
{
  int prev_color=getcolor();
  setcolor(Color);
  rectangle(CenterX, CenterY, CenterX+w, CenterY+h);
  setcolor(prev_color);
}
void Message::Show()
{
  int prev_color=getcolor();
  setcolor(Color);
  outtextxy(CenterX, CenterY, String);
  setcolor(prev_color);
}
int main()
{
  int figure_sel; *
  int direction = 1;
  int gdriver = DETECT, gmode, errorcode;

  // 
  cout<<"Select Object :\n";
  cout<<"1 - Circle\n";
  cout<<"2 - Rectangle\n";
  cout<<"3 - Message\n";
  cout<<"4 - Silinder\n";
  cout<<"5 - KonsPriyam\n";
  cout<<"Any other number - Exit\n";
  cout<<"Number: ";
   cin>>figure_sel;

  if ((figure_sel>5) || (figure_sel<1)) return 0;
  // Ё*ЁжЁ*«Ё§*жЁп Ја*дЁЄЁ
  initgraph(&gdriver, &gmode,
     "..\\BGI");
  errorcode = graphresult();
  if (errorcode != grOk)
  {
     cerr<<"Graphics error";
     cerr<<grapherrormsg(errorcode);
     exit(1);
  }
  
  Figure *F1;

  switch (figure_sel)
     {         // Circle
      case 1: {F1 = new Circle(10,10,50);break;}
	       // Rectangle
      case 2: {F1 = new Rectangle(10,10,60,50);break;}
	       // Message
      case 3: {F1 = new Message(10,10,"C++!");break;}
	       // Silinder
      case 4: {F1 = new Silinder (10,10,30);break;}
	       // KonsPriyam
      case 5: {F1 = new KonsPriyam (10,10,50);break;}
     };

  F1->Show();
    int maxcolor = getmaxcolor();
  for (int color = 0; !kbhit(); color++)
    {
      if (color>maxcolor)
	{color=0; direction*=-1;}
      F1->Move(10*direction,10*direction);
      F1->SetNewColor(color);
      delay(100);
    };
  F1->Hide();
    delete F1;
    closegraph();
  return 0;
}

Последний раз редактировалось Stilet; 16.06.2013 в 17:13.
xWoWx вне форума Ответить с цитированием
Старый 16.06.2013, 20:33   #2
xWoWx
Пользователь
 
Регистрация: 03.04.2012
Сообщений: 34
По умолчанию

вообщем код конуса вписал, но компилятор ругается.
Код:
#include<iostream.h>          
#include <conio.h>
#include <stdio.h>
#include <stdlib.h>
#include <dos.h>
#include <math.h>
#include <string.h>
#include <graphics.h>
class Figure
{
protected:
  int Color;
  int CenterX;
  int CenterY;
public:
    Figure(int iCenterX, int iCenterY)
  {
    Color = RED;
    CenterX = iCenterX;
    CenterY = iCenterY;
  }
  void SetNewColor(int NewColor)
  {
    Hide();
    Color=NewColor;
    Show();
  }
   virtual void Show() = 0;
    virtual void Hide()
  {
    int prev_col = Color;
    Color = getbkcolor();
    Show();
    Color = prev_col;
  }
  void Move(int DeltaX, int DeltaY)
  {
    Hide();
    CenterX+=DeltaX;
    CenterY+=DeltaY;
    Show();
  }
    virtual ~Figure()
  {};
};
class Circle: public Figure
{
private:
  int Radius;
public:
  Circle(int iCenterX, int iCenterY, int iRadius) :
    Figure(iCenterX, iCenterY)
  {
     Radius = iRadius;
  }
  void Show();
};
class Rectangle: public Figure
{
private:
  int h;
  int w;
public:
  Rectangle(int iCenterX, int iCenterY, int ih, int iw) :
    Figure(iCenterX, iCenterY)
  {
     h = ih;
     w = iw;
  }
  void Show();
};
class Message: public Figure
{
private:
  char*String;
public:
  Message(int iCenterX, int iCenterY, char* Msg) :
    Figure(iCenterX, iCenterY)
  {
     String = new char [strlen(Msg)+1];
     strcpy(String, Msg);
  }
  void Show();
  ~Message()
  {
     delete String;
  }
};
class Silinder: public Figure
{
private:
  int Radius;
public:
  Silinder( int iCenterX,  int iCenterY,  int iRadius ):
    Figure(iCenterX, iCenterY)
  {
     Radius = iRadius;
  }
    void Show();
};
class KonsPriyam: public Figure
{
private:
  int Size;
public:
  KonsPriyam( int iCenterX,
	 int iCenterY,
	 int iSize ):
    Figure(iCenterX, iCenterY)
  {
     Size = iSize;
  }
void Show();
};
class Conus: public Figure
{
private:
  int xRadius;
  int yRadius;
  int h;
public:
  Conus(int iCenterX, int iCenterY, int xR, int yR, int ih) :
	Figure(iCenterX, iCenterY)
  {
	 xRadius = xR;
	 yRadius = yR;
	 h = ih;
  }
void Silinder::Show()
{
  int prev_color=getcolor();
  setcolor(Color);
  line(CenterX - Radius / 2, CenterY - Radius / 2, CenterX - Radius / 2, CenterY + Radius / 2);
  line(CenterX + Radius / 2, CenterY - Radius / 2, CenterX + Radius / 2, CenterY + Radius / 2);
  ellipse(CenterX, CenterY + Radius / 2, 0,360, Radius / 2, Radius / 3);
  ellipse(CenterX, CenterY - Radius / 2, 0,360, Radius / 2, Radius / 3);
  setcolor(prev_color);
}
void Circle::Show()
{
  int prev_color=getcolor();
  setcolor(Color);
  circle(CenterX, CenterY, Radius);
  setcolor(prev_color);
}
void KonsPriyam::Show()
{
  int prev_color=getcolor();
  setcolor(Color);
  rectangle( CenterX - Size / 2, CenterY - Size / 2,
	     CenterX + Size / 2, CenterY + Size / 2);
  rectangle( CenterX - Size / 3, CenterY - Size / 3,
	     CenterX + Size / 3, CenterY + Size / 3);
 setcolor(prev_color);
}
  void Conus::Show()
  {
	int prev_color=getcolor();
	setcolor(Color);
	ellipse(CenterX, CenterY+h/2, 0, 360, xRadius, yRadius);
	moveto(CenterX-xRadius,CenterY+h/2);
	linerel(xRadius,-h);
	linerel(xRadius,h);
	setcolor(prev_color);
  }
void Rectangle::Show()
{
  int prev_color=getcolor();
  setcolor(Color);
  rectangle(CenterX, CenterY, CenterX+w, CenterY+h);
  setcolor(prev_color);
}
void Message::Show()
{
  int prev_color=getcolor();
  setcolor(Color);
  outtextxy(CenterX, CenterY, String);
  setcolor(prev_color);
}
int main()
{
  int figure_sel;
  int direction = 1;
  int gdriver = DETECT, gmode, errorcode;
  cout<<"Select Object :\n";
  cout<<"1 - Circle\n";
  cout<<"2 - Rectangle\n";
  cout<<"3 - Message\n";
  cout<<"4 - Silinder\n";
  cout<<"5 - KonsPriyam\n";
cout<<"6 - Conus \n";
  cout<<"Any other number - Exit\n";
  cout<<"Number: ";
   cin>>figure_sel;
  if ((figure_sel>5) || (figure_sel<1)) return 0;
    initgraph(&gdriver, &gmode,
     "..\\BGI");
  errorcode = graphresult();
  if (errorcode != grOk)
  {
     cerr<<"Graphics error";
     cerr<<grapherrormsg(errorcode);
     exit(1);
  }
    Figure *F1;
  switch (figure_sel)
     {
      case 1: {F1 = new Circle(10,10,50);break;}
      case 2: {F1 = new Rectangle(10,10,60,50);break;}

      case 3: {F1 = new Message(10,10,"C++!");break;}

      case 4: {F1 = new Silinder (10,10,30);break;}

      case 5: {F1 = new KonsPriyam (10,10,50);break;}

      case 6: {F1 = new Conus (10,10,60);break;}
     };
  F1->Show();
  int maxcolor = getmaxcolor();
  for (int color = 0; !kbhit(); color++)
    {
      if (color>maxcolor)
	{color=0; direction*=-1;}
      F1->Move(10*direction,10*direction);
      F1->SetNewColor(color);
      delay(100);
    };
  F1->Hide();
    delete F1;
    closegraph();
  return 0;
  }

Последний раз редактировалось Stilet; 16.06.2013 в 21:18.
xWoWx вне форума Ответить с цитированием
Старый 16.06.2013, 21:19   #3
Stilet
Белик Виталий :)
Старожил
 
Аватар для Stilet
 
Регистрация: 23.07.2007
Сообщений: 57,097
По умолчанию

На что ругается? Уж не на автора ли?
I'm learning to live...
Stilet вне форума Ответить с цитированием
Старый 17.06.2013, 07:12   #4
xWoWx
Пользователь
 
Регистрация: 03.04.2012
Сообщений: 34
По умолчанию

Цитата:
Сообщение от Stilet Посмотреть сообщение
На что ругается? Уж не на автора ли?
Вот на это
Изображения
Тип файла: jpg Безымянный.jpg (230.9 Кб, 133 просмотров)
xWoWx вне форума Ответить с цитированием
Старый 17.06.2013, 08:11   #5
Stilet
Белик Виталий :)
Старожил
 
Аватар для Stilet
 
Регистрация: 23.07.2007
Сообщений: 57,097
По умолчанию

Cannot have чего?
Полностью текст ошибки привести не желаешь?
I'm learning to live...
Stilet вне форума Ответить с цитированием
Старый 17.06.2013, 14:52   #6
xWoWx
Пользователь
 
Регистрация: 03.04.2012
Сообщений: 34
По умолчанию

Вот ошибки
Изображения
Тип файла: jpg 1.jpg (269.3 Кб, 132 просмотров)
Тип файла: jpg 2.jpg (160.6 Кб, 79 просмотров)
Тип файла: jpg 3.jpg (160.4 Кб, 74 просмотров)
Тип файла: jpg 4.jpg (155.0 Кб, 64 просмотров)
Тип файла: jpg 5.jpg (160.6 Кб, 73 просмотров)
xWoWx вне форума Ответить с цитированием
Старый 17.06.2013, 20:03   #7
Ezhik Kihze
Форумчанин
 
Регистрация: 24.12.2012
Сообщений: 639
По умолчанию

Да прокрутите же текст ошибок вправо, вам уже сказали... или вы и в обычной жизни полупредложениями разговариваете?
ICQ: 677936656 Gmail: ekEmbed@gmail.com
Ezhik Kihze вне форума Ответить с цитированием
Старый 17.06.2013, 20:18   #8
xWoWx
Пользователь
 
Регистрация: 03.04.2012
Сообщений: 34
По умолчанию

Цитата:
Сообщение от Ezhik Kihze Посмотреть сообщение
Да прокрутите же текст ошибок вправо, вам уже сказали... или вы и в обычной жизни полупредложениями разговариваете?
Ошибки одинаковые идут в последовательности. Прокрутывал, но они слетают опять в 0, тоесть все строки вправо прокрутить неполучается
xWoWx вне форума Ответить с цитированием
Старый 17.06.2013, 20:39   #9
xWoWx
Пользователь
 
Регистрация: 03.04.2012
Сообщений: 34
По умолчанию

перенес прогу в другую папку и перепесал пути графики тоже самое.
Изображения
Тип файла: jpg 11.jpg (225.9 Кб, 131 просмотров)
xWoWx вне форума Ответить с цитированием
Старый 17.06.2013, 21:06   #10
BDA
МегаМодератор
СуперМодератор
 
Аватар для BDA
 
Регистрация: 09.11.2010
Сообщений: 7,429
По умолчанию

При беглом просмотре не увидел завершающих }; у класса конуса. Да и метода show() нет у этого класса.
Пишите язык программирования - это форум программистов, а не экстрасенсов. (<= это подпись )
BDA вне форума Ответить с цитированием
Ответ


Купить рекламу на форуме - 42 тыс руб за месяц



Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
написание программы в С++ 1apre Помощь студентам 0 13.04.2013 15:21
Написание программы Bond21 Фриланс 3 07.03.2012 16:05
Написание программы. AllowFrosty Софт 6 23.02.2012 11:00
Написание программы Dj Troy Общие вопросы C/C++ 1 17.04.2011 16:19